diff options
Diffstat (limited to 'packages/contract_templates/partials/callAsync.handlebars')
-rw-r--r-- | packages/contract_templates/partials/callAsync.handlebars | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars index a6f4abdf2..58fb2f09c 100644 --- a/packages/contract_templates/partials/callAsync.handlebars +++ b/packages/contract_templates/partials/callAsync.handlebars @@ -5,20 +5,21 @@ async callAsync( defaultBlock?: BlockParam, ): Promise<{{> return_type outputs=outputs}}> { const self = this as any as {{contractName}}Contract; - const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; + const functionSignature = '{{this.functionSignature}}'; + const inputAbi = self._lookupAbi(functionSignature).inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); - const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}( {{> params inputs=inputs}} - ).data; + ) as ethers.CallDescription; + const encodedData = ethersFunction.data; const callDataWithDefaults = await self._applyDefaultsToTxDataAsync( { data: encodedData, } ) const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs; - const outputParamsTypes = _.map(outputAbi, 'type'); - let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any; resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}}; |