Files
openzeppelin-contracts/test/helpers/sendTransaction.js
Roman Exempliarov a3bb56769e Remove lodash from tests (#1323)
(cherry picked from commit d062352de7)
2018-10-20 20:59:13 +00:00

22 lines
622 B
JavaScript

const ethjsABI = require('ethjs-abi');
function findMethod (abi, name, args) {
for (let i = 0; i < abi.length; i++) {
const methodArgs = abi[i].inputs.map(input => input.type).join(',');
if ((abi[i].name === name) && (methodArgs === args)) {
return abi[i];
}
}
}
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));
}
module.exports = {
findMethod,
sendTransaction,
};