Add more tests for ERC721

This commit is contained in:
Santiago Palladino
2018-03-08 19:19:15 -03:00
parent 71cbc511ec
commit 3745025a1e
8 changed files with 764 additions and 532 deletions

View File

@ -0,0 +1,17 @@
const _ = require('lodash');
const ethjsABI = require('ethjs-abi');
export function findMethod (abi, name, args) {
for (var i = 0; i < abi.length; i++) {
const methodArgs = _.map(abi[i].inputs, 'type').join(',');
if ((abi[i].name === name) && (methodArgs === args)) {
return abi[i];
}
}
}
export default function sendTransaction (target, name, argsTypes, argsValues, opts) {
const abiMethod = findMethod(target.abi, name, argsTypes);
const encodedData = ethjsABI.encodeMethod(abiMethod, argsValues);
return target.sendTransaction(Object.assign({ data: encodedData }, opts));
}