Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (signature, params = []) => {
const sigBytes = abi.encodeFunctionSignature(signature)
const types = signature.replace(')', '').split('(')[1]
// No params, return signature directly
if (types === '') {
return sigBytes
}
const paramBytes = abi.encodeParameters(types.split(','), params)
return `${sigBytes}${paramBytes.slice(2)}`
}
const encodeCalldata = (signature, params) => {
const sigBytes = ABI.encodeFunctionSignature(signature)
const types = signature.replace(')', '').split('(')[1]
// No params, return signature directly
if (types === '') {
return sigBytes
}
const paramBytes = ABI.encodeParameters(types.split(','), params)
return `${sigBytes}${paramBytes.slice(2)}`
}
// makerQuantity.quantity,
// takerQuantity.quantity,
// ).call();
const policyManager = await getContract(
environment,
Contracts.PolicyManager,
policyManagerAddress,
);
const exchangeAddress =
environment.deployment.exchangeConfigs[Exchanges.MatchingMarket].exchange;
const result = await policyManager.methods
.preValidate(
web3EthAbi.encodeFunctionSignature(FunctionSignatures.takeOrder),
[
'0x0000000000000000000000000000000000000000', // orderAddresses[0],
tradingAddress.toString(), // orderAddresses[1],
makerQuantity.token.address.toString(), // orderAddresses[2],
takerQuantity.token.address.toString(), // orderAddresses[3],
exchangeAddress.toString(), // exchanges[exchangeIndex].exchange
],
[
makerQuantity.quantity.toString(), // orderValues[0],
takerQuantity.quantity.toString(), // orderValues[1],
fillTakerTokenAmount.quantity.toString(), // orderValues[6]
],
`0x${Number(id)
.toString(16)
.padStart(64, '0')}`, // identifier
)
// makerQuantity.quantity,
// takerQuantity.quantity,
// ).call();
const policyManager = await getContract(
environment,
Contracts.PolicyManager,
policyManagerAddress,
);
const exchangeAddress =
environment.deployment.exchangeConfigs[Exchanges.MatchingMarket].exchange;
const result = await policyManager.methods
.preValidate(
web3EthAbi.encodeFunctionSignature(FunctionSignatures.makeOrder),
[
tradingAddress.toString(), // orderAddresses[0],
'0x0000000000000000000000000000000000000000', // orderAddresses[1],
makerQuantity.token.address.toString(), // orderAddresses[2],
takerQuantity.token.address.toString(), // orderAddresses[3],
exchangeAddress.toString(), // exchanges[exchangeIndex].exchange
],
[
makerQuantity.quantity.toString(), // orderValues[0],
takerQuantity.quantity.toString(), // orderValues[1],
'0', // orderValues[6]
],
'0x0', // identifier
)
.call();
export const getFunctionABISignature = (abi: any, functionName: string) => {
return Web3EthAbi.encodeFunctionSignature(
findFunctionDefinition(abi, functionName),
);
};
function abiEncode(joinedSignature) {
return web3EthAbi.encodeFunctionSignature(joinedSignature);
}
const method = call.abi.find((abi) =>
abi.type === 'function' &&
methodId === ABI.encodeFunctionSignature(abi))
sigs.map(sig => web3EthAbi.encodeFunctionSignature(sig)),
];