Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
erc20.address = address;
erc20.provider = provider;
erc20.contract = new Contract(abi, address, {
provider: provider
});
const methods = {};
// @ts-ignore
for (const fnName of Object.keys(erc20.contract.getABI())) {
// @ts-ignore
const fnAbi = erc20.contract.getABI()[fnName];
if (fnAbi.type === "constructor") {
continue;
}
const args = getArgTypes(fnAbi);
const header = getHeaderHash(fnAbi, args);
// @ts-ignore
methods[header] = {
name: fnName,
inputsNames: args.map(i => {
return `${i.name}`;
}),
inputsTypes: args.map(i => {
return `${i.type}`;
})
};
}
erc20.methods = methods;
return erc20;
}
vita.address = address;
vita.provider = provider;
vita.contract = new Contract(ABI, address, {
provider: provider
});
const methods = {};
// @ts-ignore
for (const fnName of Object.keys(vita.contract.getABI())) {
// @ts-ignore
const fnAbi = vita.contract.getABI()[fnName];
if (fnAbi.type === "constructor") {
continue;
}
const args = getArgTypes(fnAbi);
const header = getHeaderHash(fnAbi, args);
// @ts-ignore
methods[header] = {
name: fnName,
inputsNames: args.map(i => {
return `${i.name}`;
}),
inputsTypes: args.map(i => {
return `${i.type}`;
})
};
}
vita.methods = methods;
return vita;
if (data.length < 8) {
window.console.warn("input data error");
return { method: data, data: {} };
}
const method = data.substr(0, 8);
const ABI = JSON.parse(abi);
const erc20: ERC20 = ERC20.create(contractAddress, getAntenna().iotx, ABI);
const contractAbi = erc20.contract.getABI() as AbiByFunc;
for (const fnName of Object.keys(contractAbi)) {
const fnAbi = contractAbi[fnName];
if (fnAbi.type === "constructor") {
continue;
}
const args = getArgTypes(fnAbi);
const header = getHeaderHash(fnAbi, args);
if (method === header) {
const methodDef = {
name: fnName,
inputsNames: args.map(i => {
return `${i.name}`;
}),
inputsTypes: args.map(i => {
return `${i.type}`;
})
};
const params = ethereumjs.rawDecode(
methodDef.inputsTypes,
Buffer.from(data.substring(8), "hex")