diff options
author | Fabio Berger <me@fabioberger.com> | 2019-01-15 22:10:50 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2019-01-15 22:10:50 +0800 |
commit | ae147e615af9da32ca3da0b92ef77815061ad5be (patch) | |
tree | d7bae435a99c668d02cc9ee9d84619c3056509f6 /packages/abi-gen-templates | |
parent | 98579300c1f78d8c360fa960cc73ffacb1012e91 (diff) | |
parent | 18084588ea9fa724d6e32c9a49c79d49f189ba7c (diff) | |
download | dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar.gz dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar.bz2 dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar.lz dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar.xz dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.tar.zst dexon-0x-contracts-ae147e615af9da32ca3da0b92ef77815061ad5be.zip |
Merge branch 'development' into fix/dev-tools-pages/finalTouches
* development: (87 commits)
Update packages/sol-tracing-utils/src/trace_collection_subprovider.ts
Make mapping namings direct
Remove unused tslint disable
Revert "Remove logAsyncErrors hack"
Remove logAsyncErrors hack
Refactor logAsyncErrors to follow our conventions
Export Sources and SourceCodes out of tracing utils
Replace console.log with logUtils.log (#1515)
strict decoding of return values using generics
makerAssetFillAmount -> takerAssetFillAmount
Ran prettier
Linter
Fix build after rebase
Style cleanup for Compressed Calldata in Contract Wrappers PR
Use simpler `_.find` to locate fillOrderBai
Updated dutch auction wrapper
Added back abi-gen-wrappers
Renamed signatureParser.ts to signature_parser.ts
Renamed decode rule `structsAsObjects` to `shouldConvertStructsToObjects`
circle build failed. New commit to resubmit job.
...
Diffstat (limited to 'packages/abi-gen-templates')
-rw-r--r-- | packages/abi-gen-templates/contract.handlebars | 2 | ||||
-rw-r--r-- | packages/abi-gen-templates/partials/callAsync.handlebars | 17 | ||||
-rw-r--r-- | packages/abi-gen-templates/partials/tx.handlebars | 13 |
3 files changed, 10 insertions, 22 deletions
diff --git a/packages/abi-gen-templates/contract.handlebars b/packages/abi-gen-templates/contract.handlebars index 9b2a2b336..7e7171c70 100644 --- a/packages/abi-gen-templates/contract.handlebars +++ b/packages/abi-gen-templates/contract.handlebars @@ -85,7 +85,7 @@ export class {{contractName}}Contract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('{{contractName}}', abi, address, provider, txDefaults); - classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']); } } // tslint:disable:max-file-line-count // tslint:enable:no-unbound-method diff --git a/packages/abi-gen-templates/partials/callAsync.handlebars b/packages/abi-gen-templates/partials/callAsync.handlebars index ddbbe7508..ab9f2c21c 100644 --- a/packages/abi-gen-templates/partials/callAsync.handlebars +++ b/packages/abi-gen-templates/partials/callAsync.handlebars @@ -4,12 +4,7 @@ async callAsync( defaultBlock?: BlockParam, ): Promise<{{> return_type outputs=outputs}}> { const self = this as any as {{contractName}}Contract; - 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 encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -20,9 +15,9 @@ async callAsync( ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - 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)); - return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}}; + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(rawCallResult); + // tslint:enable boolean-naming + return result; }, diff --git a/packages/abi-gen-templates/partials/tx.handlebars b/packages/abi-gen-templates/partials/tx.handlebars index b39156583..0f1027fae 100644 --- a/packages/abi-gen-templates/partials/tx.handlebars +++ b/packages/abi-gen-templates/partials/tx.handlebars @@ -9,10 +9,7 @@ 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 encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -33,9 +30,7 @@ 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 encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -51,9 +46,7 @@ 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 abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]); return abiEncodedTransactionData; }, {{> callAsync}} |