diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-18 10:26:03 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-01-15 02:49:29 +0800 |
commit | 285fb3deadd0413bf993557575a3f96a840f0e10 (patch) | |
tree | 8970de6db324e3773146f61265e0b44d03976a60 /packages/abi-gen-templates/partials | |
parent | 797d7c7878e33ce012259a6a5db5335e9dc838ba (diff) | |
download | dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.gz dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.bz2 dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.lz dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.xz dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.zst dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.zip |
Progress
Diffstat (limited to 'packages/abi-gen-templates/partials')
-rw-r--r-- | packages/abi-gen-templates/partials/callAsync.handlebars | 8 | ||||
-rw-r--r-- | packages/abi-gen-templates/partials/tx.handlebars | 16 |
2 files changed, 10 insertions, 14 deletions
diff --git a/packages/abi-gen-templates/partials/callAsync.handlebars b/packages/abi-gen-templates/partials/callAsync.handlebars index ddbbe7508..0fe8b0463 100644 --- a/packages/abi-gen-templates/partials/callAsync.handlebars +++ b/packages/abi-gen-templates/partials/callAsync.handlebars @@ -7,9 +7,8 @@ async callAsync( const functionSignature = '{{this.functionSignature}}'; const inputAbi = self._lookupAbi(functionSignature).inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}; - const encodedData = ethersFunction.encode([{{> params inputs=inputs}}]); + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const encodedData = abiEncoder.encode([{{> params inputs=inputs}}]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -20,7 +19,8 @@ async callAsync( ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); + const decodingRules = {structsAsObjects: false}; + let resultArray = abiEncoder.decodeReturnValues(rawCallResult, decodingRules); const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs; resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); diff --git a/packages/abi-gen-templates/partials/tx.handlebars b/packages/abi-gen-templates/partials/tx.handlebars index b39156583..102316b44 100644 --- a/packages/abi-gen-templates/partials/tx.handlebars +++ b/packages/abi-gen-templates/partials/tx.handlebars @@ -9,10 +9,8 @@ public {{this.tsName}} = { {{/this.payable}} ): Promise<string> { const self = this as any as {{contractName}}Contract; - const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; - [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); - const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + const encodedData = abiEncoder.encode([{{> params inputs=inputs}}], {optimize: false}); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -33,9 +31,8 @@ public {{this.tsName}} = { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as {{contractName}}Contract; - const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; - [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + const encodedData = abiEncoder.encode([{{> params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -51,9 +48,8 @@ public {{this.tsName}} = { {{> typed_params inputs=inputs}} ): string { const self = this as any as {{contractName}}Contract; - const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; - [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + const abiEncodedTransactionData = abiEncoder.encode([{{> params inputs=inputs}}]); return abiEncodedTransactionData; }, {{> callAsync}} |