Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return `${i.name}`;
}),
inputsTypes: args.map(i => {
return `${i.type}`;
})
};
const params = ethereumjs.rawDecode(
methodDef.inputsTypes,
Buffer.from(data.substring(8), "hex")
);
const values = {};
for (let i = 0; i < methodDef.inputsTypes.length; i++) {
if (methodDef.inputsTypes[i] === "address") {
params[i] = fromBytes(
Buffer.from(params[i].toString(), "hex")
).string();
}
// @ts-ignore
values[method.inputsNames[i]] = params[i];
}
return {
method: methodDef.name,
data: values
};
}
}
window.console.warn("can not found method");
return { method: data, data: {} };
throw new Error("input data error");
}
const methodKey = data.substr(0, 8);
const method = this.methods[methodKey];
if (!method) {
throw new Error(`method ${methodKey} is not erc20 method`);
}
const params = ethereumjs.rawDecode(
method.inputsTypes,
Buffer.from(data.substring(8), "hex")
);
const values = {};
for (let i = 0; i < method.inputsTypes.length; i++) {
if (method.inputsTypes[i] === "address") {
params[i] = fromBytes(
Buffer.from(params[i].toString(), "hex")
).string();
}
// @ts-ignore
values[method.inputsNames[i]] = params[i];
}
return {
method: method.name,
data: values
};
}
}