aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util/multi_sig_wrapper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/util/multi_sig_wrapper.ts')
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts60
1 files changed, 30 insertions, 30 deletions
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
index ca9f07ce5..0e2e671ec 100644
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ b/packages/contracts/util/multi_sig_wrapper.ts
@@ -6,34 +6,34 @@ import * as Web3 from 'web3';
import { ContractInstance, TransactionDataParams } from './types';
export class MultiSigWrapper {
- private _multiSig: ContractInstance;
- public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
- const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
- if (_.isUndefined(abiEntity)) {
- throw new Error(`Did not find abi entry for name: ${name}`);
- }
- const types = _.map(abiEntity.inputs, input => input.type);
- const funcSig = ethUtil.bufferToHex(ABI.methodID(name, types));
- const argsData = _.map(args, arg => {
- const target = _.isBoolean(arg) ? +arg : arg;
- const targetBuff = ethUtil.toBuffer(target);
- return ethUtil.setLengthLeft(targetBuff, 32).toString('hex');
- });
- return funcSig + argsData.join('');
- }
- constructor(multiSigContractInstance: ContractInstance) {
- this._multiSig = multiSigContractInstance;
- }
- public async submitTransactionAsync(
- destination: string,
- from: string,
- dataParams: TransactionDataParams,
- value: number = 0,
- ) {
- const { name, abi, args = [] } = dataParams;
- const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
- return this._multiSig.submitTransaction(destination, value, encoded, {
- from,
- });
- }
+ private _multiSig: ContractInstance;
+ public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
+ const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
+ if (_.isUndefined(abiEntity)) {
+ throw new Error(`Did not find abi entry for name: ${name}`);
+ }
+ const types = _.map(abiEntity.inputs, input => input.type);
+ const funcSig = ethUtil.bufferToHex(ABI.methodID(name, types));
+ const argsData = _.map(args, arg => {
+ const target = _.isBoolean(arg) ? +arg : arg;
+ const targetBuff = ethUtil.toBuffer(target);
+ return ethUtil.setLengthLeft(targetBuff, 32).toString('hex');
+ });
+ return funcSig + argsData.join('');
+ }
+ constructor(multiSigContractInstance: ContractInstance) {
+ this._multiSig = multiSigContractInstance;
+ }
+ public async submitTransactionAsync(
+ destination: string,
+ from: string,
+ dataParams: TransactionDataParams,
+ value: number = 0,
+ ) {
+ const { name, abi, args = [] } = dataParams;
+ const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
+ return this._multiSig.submitTransaction(destination, value, encoded, {
+ from,
+ });
+ }
}