From 93b2736d6533f983aeb74005004de7f40eb35851 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 23 Feb 2018 14:13:35 -0800 Subject: Use the same templates as 0x.js --- .../contract_templates/partials/call.handlebars | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/contract_templates/partials/call.handlebars (limited to 'packages/contract_templates/partials/call.handlebars') diff --git a/packages/contract_templates/partials/call.handlebars b/packages/contract_templates/partials/call.handlebars new file mode 100644 index 000000000..7ac3e1ee3 --- /dev/null +++ b/packages/contract_templates/partials/call.handlebars @@ -0,0 +1,23 @@ +public {{this.name}} = { + async callAsync( + {{> typed_params inputs=inputs}} + defaultBlock?: Web3.BlockParam, + ): Promise<{{> return_type outputs=outputs}}> { + const self = this as {{contractName}}Contract; + const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs; + [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); + const callDescription = self._ethersInterface.functions.{{this.name}}( + {{> params inputs=inputs}} + ) as ethersContracts.CallDescription; + const callData = await self._applyDefaultsToTxDataAsync( + { + data: callDescription.data, + } + ) + const rawCallResult = await self._web3Wrapper.callAsync(callData); + let resultArray = callDescription.parse(rawCallResult); + const outputAbi = _.find(this.abi, {name: '{{this.name}}'}).outputs; + resultArray = BaseContract._transformABIData(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}}; + }, +}; -- cgit v1.2.3