Fix indentations
This commit is contained in:
		| @@ -6,29 +6,29 @@ import * as Web3 from 'web3'; | ||||
| import {ContractInstance, TransactionDataParams} from './types'; | ||||
|  | ||||
| export class MultiSigWrapper { | ||||
|   private multiSig: ContractInstance; | ||||
|   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 = this.encodeFnArgs(name, abi, args); | ||||
|     return this.multiSig.submitTransaction(destination, value, encoded, {from}); | ||||
|   } | ||||
|   public 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}`); | ||||
|     private multiSig: ContractInstance; | ||||
|     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 = this.encodeFnArgs(name, abi, args); | ||||
|         return this.multiSig.submitTransaction(destination, value, encoded, {from}); | ||||
|     } | ||||
|     public 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(''); | ||||
|     } | ||||
|     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(''); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user