diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2019-01-16 02:43:55 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2019-01-16 02:43:55 +0800 |
commit | 600b44c9620494c976b5aac6e8a1912543cda81c (patch) | |
tree | fd78c65dd2fdd7b1cbee1b5eff97a95a984a9186 /packages | |
parent | 8a8a5332d76ae8429d1c6449e0ea693a2e8c8a8a (diff) | |
parent | f570f80674c22f69712c45e8e3c48e948b51f357 (diff) | |
download | dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar.gz dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar.bz2 dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar.lz dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar.xz dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.tar.zst dexon-sol-tools-600b44c9620494c976b5aac6e8a1912543cda81c.zip |
Merge branch 'development' into feature/instant/asset-buyer-check-liquidity
Diffstat (limited to 'packages')
224 files changed, 4872 insertions, 5296 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index f11293e6d..a849a35a2 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 258dee66a..c389c0e00 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v3.0.1 - _January 11, 2019_ + + * Dependencies updated + ## v3.0.0 - _January 9, 2019_ * Export `MultiAssetData`, `MultiAssetDataWithRecursiveDecoding`, `ObjectMap`, and `SingleAssetData` from types. No longer export `AssetData`. (#1363) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 74522c784..ca990c0a7 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -42,11 +42,11 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/contract-addresses": "^2.1.0", - "@0x/dev-utils": "^1.0.22", - "@0x/migrations": "^2.3.0", - "@0x/tslint-config": "^2.0.0", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/contract-addresses": "^2.2.0", + "@0x/dev-utils": "^1.0.24", + "@0x/migrations": "^2.4.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/node": "*", @@ -72,18 +72,18 @@ "webpack": "^4.20.2" }, "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/base-contract": "^3.0.11", - "@0x/contract-wrappers": "^4.2.0", - "@0x/order-utils": "^3.1.0", - "@0x/order-watcher": "^2.4.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/assert": "^1.0.23", + "@0x/base-contract": "^3.0.13", + "@0x/contract-wrappers": "^5.0.0", + "@0x/order-utils": "^3.1.2", + "@0x/order-watcher": "^2.4.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/web3-provider-engine": "^14.0.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5", "web3-provider-engine": "14.0.6" diff --git a/packages/abi-gen-templates/CHANGELOG.json b/packages/abi-gen-templates/CHANGELOG.json index baf852ad5..b825c4f1f 100644 --- a/packages/abi-gen-templates/CHANGELOG.json +++ b/packages/abi-gen-templates/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547561734, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1543401373, "version": "1.0.1", "changes": [ diff --git a/packages/abi-gen-templates/CHANGELOG.md b/packages/abi-gen-templates/CHANGELOG.md index 1c3f21c6c..5dd6d03e0 100644 --- a/packages/abi-gen-templates/CHANGELOG.md +++ b/packages/abi-gen-templates/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.2 - _January 15, 2019_ + + * Dependencies updated + ## v1.0.1 - _November 28, 2018_ * Dependencies updated 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/package.json b/packages/abi-gen-templates/package.json index 09872ab49..af66aeba0 100644 --- a/packages/abi-gen-templates/package.json +++ b/packages/abi-gen-templates/package.json @@ -1,6 +1,6 @@ { "name": "@0x/abi-gen-templates", - "version": "1.0.1", + "version": "1.0.2", "engines": { "node": ">=6.12" }, 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}} diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json index e73fa92bb..381b37cda 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.json +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -1,5 +1,24 @@ [ { + "version": "2.2.0", + "changes": [ + { + "note": "Added `MultiAssetProxy`", + "pr": 1503 + } + ], + "timestamp": 1547561734 + }, + { + "timestamp": 1547225310, + "version": "2.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.1.0", "changes": [ { diff --git a/packages/abi-gen-wrappers/CHANGELOG.md b/packages/abi-gen-wrappers/CHANGELOG.md index 4090e045a..294f39439 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.md +++ b/packages/abi-gen-wrappers/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.2.0 - _January 15, 2019_ + + * Added `MultiAssetProxy` (#1503) + +## v2.1.1 - _January 11, 2019_ + + * Dependencies updated + ## v2.1.0 - _January 9, 2019_ * Added Dutch Auction Wrapper (#1465) diff --git a/packages/abi-gen-wrappers/package.json b/packages/abi-gen-wrappers/package.json index f7d40d591..842ac024a 100644 --- a/packages/abi-gen-wrappers/package.json +++ b/packages/abi-gen-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0x/abi-gen-wrappers", - "version": "2.1.0", + "version": "2.2.0", "engines": { "node": ">=6.12" }, @@ -18,7 +18,7 @@ "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers" }, "config": { - "abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|ZRXToken).json" + "abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken).json" }, "repository": { "type": "git", @@ -30,19 +30,19 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.20", - "@0x/abi-gen-templates": "^1.0.1", - "@0x/tslint-config": "^2.0.0", - "@0x/types": "^1.5.0", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", - "ethereum-types": "^1.1.4", + "@0x/abi-gen": "^1.0.22", + "@0x/abi-gen-templates": "^1.0.2", + "@0x/tslint-config": "^2.0.2", + "@0x/types": "^1.5.2", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5", "shx": "^0.2.2" }, "dependencies": { - "@0x/base-contract": "^3.0.11" + "@0x/base-contract": "^3.0.13" }, "publishConfig": { "access": "public" diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts index 27f108ebc..cc42e7fb5 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -105,15 +105,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<string > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'owners(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owners; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('owners(uint256)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -125,11 +117,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owners'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owners(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public removeOwner = { @@ -138,13 +131,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('removeOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner - ]); - const encodedData = self._lookupEthersInterface('removeOwner(address)').functions.removeOwner.encode([owner + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -166,11 +153,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('removeOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('removeOwner(address)').functions.removeOwner.encode([owner + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -187,11 +170,7 @@ export class AssetProxyOwnerContract extends BaseContract { owner: string, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('removeOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('removeOwner(address)').functions.removeOwner.encode([owner + const abiEncodedTransactionData = self._strictEncodeArguments('removeOwner(address)', [owner ]); return abiEncodedTransactionData; }, @@ -202,15 +181,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'removeOwner(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeOwner; - const encodedData = ethersFunction.encode([owner + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -222,11 +193,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'removeOwner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('removeOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public revokeConfirmation = { @@ -235,13 +207,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const encodedData = self._lookupEthersInterface('revokeConfirmation(uint256)').functions.revokeConfirmation.encode([transactionId + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -263,11 +229,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('revokeConfirmation(uint256)').functions.revokeConfirmation.encode([transactionId + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -284,11 +246,7 @@ export class AssetProxyOwnerContract extends BaseContract { transactionId: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('revokeConfirmation(uint256)').functions.revokeConfirmation.encode([transactionId + const abiEncodedTransactionData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId ]); return abiEncodedTransactionData; }, @@ -299,15 +257,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'revokeConfirmation(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.revokeConfirmation; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -319,11 +269,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'revokeConfirmation'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('revokeConfirmation(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isOwner = { @@ -334,15 +285,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<boolean > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'isOwner(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isOwner; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('isOwner(address)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -354,11 +297,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isOwner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public confirmations = { @@ -370,18 +314,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<boolean > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'confirmations(uint256,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0, - index_1 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0, - index_1 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, - index_1 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmations; - const encodedData = ethersFunction.encode([index_0, + const encodedData = self._strictEncodeArguments('confirmations(uint256,address)', [index_0, index_1 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -394,11 +327,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'confirmations'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('confirmations(uint256,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public executeRemoveAuthorizedAddressAtIndex = { @@ -407,13 +341,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeRemoveAuthorizedAddressAtIndex(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const encodedData = self._lookupEthersInterface('executeRemoveAuthorizedAddressAtIndex(uint256)').functions.executeRemoveAuthorizedAddressAtIndex.encode([transactionId + const encodedData = self._strictEncodeArguments('executeRemoveAuthorizedAddressAtIndex(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -435,11 +363,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeRemoveAuthorizedAddressAtIndex(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('executeRemoveAuthorizedAddressAtIndex(uint256)').functions.executeRemoveAuthorizedAddressAtIndex.encode([transactionId + const encodedData = self._strictEncodeArguments('executeRemoveAuthorizedAddressAtIndex(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -456,11 +380,7 @@ export class AssetProxyOwnerContract extends BaseContract { transactionId: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeRemoveAuthorizedAddressAtIndex(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('executeRemoveAuthorizedAddressAtIndex(uint256)').functions.executeRemoveAuthorizedAddressAtIndex.encode([transactionId + const abiEncodedTransactionData = self._strictEncodeArguments('executeRemoveAuthorizedAddressAtIndex(uint256)', [transactionId ]); return abiEncodedTransactionData; }, @@ -471,15 +391,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'executeRemoveAuthorizedAddressAtIndex(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.executeRemoveAuthorizedAddressAtIndex; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('executeRemoveAuthorizedAddressAtIndex(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -491,11 +403,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'executeRemoveAuthorizedAddressAtIndex'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('executeRemoveAuthorizedAddressAtIndex(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public secondsTimeLocked = { @@ -505,12 +418,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'secondsTimeLocked()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.secondsTimeLocked; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('secondsTimeLocked()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -521,11 +429,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'secondsTimeLocked'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('secondsTimeLocked()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getTransactionCount = { @@ -537,18 +446,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'getTransactionCount(bool,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [pending, - executed - ] = BaseContract._formatABIDataItemList(inputAbi, [pending, - executed - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [pending, - executed - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionCount; - const encodedData = ethersFunction.encode([pending, + const encodedData = self._strictEncodeArguments('getTransactionCount(bool,bool)', [pending, executed ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -561,11 +459,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getTransactionCount'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getTransactionCount(bool,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public registerAssetProxy = { @@ -575,16 +474,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address,bool)').inputs; - [assetProxyContract, - isRegistered - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxyContract, - isRegistered - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetProxyContract, - isRegistered - ]); - const encodedData = self._lookupEthersInterface('registerAssetProxy(address,bool)').functions.registerAssetProxy.encode([assetProxyContract, + const encodedData = self._strictEncodeArguments('registerAssetProxy(address,bool)', [assetProxyContract, isRegistered ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -609,13 +499,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address,bool)').inputs; - [assetProxyContract, - isRegistered - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxyContract, - isRegistered - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('registerAssetProxy(address,bool)').functions.registerAssetProxy.encode([assetProxyContract, + const encodedData = self._strictEncodeArguments('registerAssetProxy(address,bool)', [assetProxyContract, isRegistered ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -634,13 +518,7 @@ export class AssetProxyOwnerContract extends BaseContract { isRegistered: boolean, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address,bool)').inputs; - [assetProxyContract, - isRegistered - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxyContract, - isRegistered - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('registerAssetProxy(address,bool)').functions.registerAssetProxy.encode([assetProxyContract, + const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address,bool)', [assetProxyContract, isRegistered ]); return abiEncodedTransactionData; @@ -653,18 +531,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'registerAssetProxy(address,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [assetProxyContract, - isRegistered - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxyContract, - isRegistered - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetProxyContract, - isRegistered - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.registerAssetProxy; - const encodedData = ethersFunction.encode([assetProxyContract, + const encodedData = self._strictEncodeArguments('registerAssetProxy(address,bool)', [assetProxyContract, isRegistered ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -677,11 +544,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'registerAssetProxy'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public addOwner = { @@ -690,13 +558,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('addOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner - ]); - const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -718,11 +580,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('addOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -739,11 +597,7 @@ export class AssetProxyOwnerContract extends BaseContract { owner: string, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('addOwner(address)').inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner + const abiEncodedTransactionData = self._strictEncodeArguments('addOwner(address)', [owner ]); return abiEncodedTransactionData; }, @@ -754,15 +608,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'addOwner(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [owner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addOwner; - const encodedData = ethersFunction.encode([owner + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -774,11 +620,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'addOwner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('addOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isConfirmed = { @@ -789,15 +636,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<boolean > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'isConfirmed(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isConfirmed; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('isConfirmed(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -809,11 +648,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isConfirmed'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isConfirmed(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public changeTimeLock = { @@ -822,13 +662,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; - [_secondsTimeLocked - ] = BaseContract._formatABIDataItemList(inputAbi, [_secondsTimeLocked - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_secondsTimeLocked - ]); - const encodedData = self._lookupEthersInterface('changeTimeLock(uint256)').functions.changeTimeLock.encode([_secondsTimeLocked + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -850,11 +684,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; - [_secondsTimeLocked - ] = BaseContract._formatABIDataItemList(inputAbi, [_secondsTimeLocked - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('changeTimeLock(uint256)').functions.changeTimeLock.encode([_secondsTimeLocked + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -871,11 +701,7 @@ export class AssetProxyOwnerContract extends BaseContract { _secondsTimeLocked: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; - [_secondsTimeLocked - ] = BaseContract._formatABIDataItemList(inputAbi, [_secondsTimeLocked - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('changeTimeLock(uint256)').functions.changeTimeLock.encode([_secondsTimeLocked + const abiEncodedTransactionData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked ]); return abiEncodedTransactionData; }, @@ -886,15 +712,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'changeTimeLock(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_secondsTimeLocked - ] = BaseContract._formatABIDataItemList(inputAbi, [_secondsTimeLocked - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_secondsTimeLocked - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.changeTimeLock; - const encodedData = ethersFunction.encode([_secondsTimeLocked + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -906,11 +724,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'changeTimeLock'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('changeTimeLock(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isAssetProxyRegistered = { @@ -921,15 +740,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<boolean > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'isAssetProxyRegistered(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isAssetProxyRegistered; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('isAssetProxyRegistered(address)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -941,11 +752,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isAssetProxyRegistered'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isAssetProxyRegistered(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getConfirmationCount = { @@ -956,15 +768,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'getConfirmationCount(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmationCount; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('getConfirmationCount(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -976,11 +780,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getConfirmationCount'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getConfirmationCount(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transactions = { @@ -991,15 +796,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<[string, BigNumber, string, boolean] > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'transactions(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactions; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('transactions(uint256)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1011,11 +808,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transactions'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transactions(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, BigNumber, string, boolean] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getOwners = { @@ -1025,12 +823,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<string[] > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'getOwners()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOwners; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('getOwners()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -1041,11 +834,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getOwners'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getOwners()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getTransactionIds = { @@ -1059,24 +853,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber[] > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'getTransactionIds(uint256,uint256,bool,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [from, - to, - pending, - executed - ] = BaseContract._formatABIDataItemList(inputAbi, [from, - to, - pending, - executed - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [from, - to, - pending, - executed - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionIds; - const encodedData = ethersFunction.encode([from, + const encodedData = self._strictEncodeArguments('getTransactionIds(uint256,uint256,bool,bool)', [from, to, pending, executed @@ -1091,11 +868,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getTransactionIds'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getTransactionIds(uint256,uint256,bool,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getConfirmations = { @@ -1106,15 +884,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<string[] > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'getConfirmations(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmations; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('getConfirmations(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1126,11 +896,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getConfirmations'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getConfirmations(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transactionCount = { @@ -1140,12 +911,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'transactionCount()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactionCount; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('transactionCount()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -1156,11 +922,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transactionCount'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transactionCount()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public changeRequirement = { @@ -1169,13 +936,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; - [_required - ] = BaseContract._formatABIDataItemList(inputAbi, [_required - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_required - ]); - const encodedData = self._lookupEthersInterface('changeRequirement(uint256)').functions.changeRequirement.encode([_required + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1197,11 +958,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; - [_required - ] = BaseContract._formatABIDataItemList(inputAbi, [_required - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('changeRequirement(uint256)').functions.changeRequirement.encode([_required + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1218,11 +975,7 @@ export class AssetProxyOwnerContract extends BaseContract { _required: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; - [_required - ] = BaseContract._formatABIDataItemList(inputAbi, [_required - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('changeRequirement(uint256)').functions.changeRequirement.encode([_required + const abiEncodedTransactionData = self._strictEncodeArguments('changeRequirement(uint256)', [_required ]); return abiEncodedTransactionData; }, @@ -1233,15 +986,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'changeRequirement(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_required - ] = BaseContract._formatABIDataItemList(inputAbi, [_required - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_required - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.changeRequirement; - const encodedData = ethersFunction.encode([_required + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1253,11 +998,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'changeRequirement'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('changeRequirement(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public confirmTransaction = { @@ -1266,13 +1012,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const encodedData = self._lookupEthersInterface('confirmTransaction(uint256)').functions.confirmTransaction.encode([transactionId + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1294,11 +1034,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('confirmTransaction(uint256)').functions.confirmTransaction.encode([transactionId + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1315,11 +1051,7 @@ export class AssetProxyOwnerContract extends BaseContract { transactionId: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('confirmTransaction(uint256)').functions.confirmTransaction.encode([transactionId + const abiEncodedTransactionData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId ]); return abiEncodedTransactionData; }, @@ -1330,15 +1062,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'confirmTransaction(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmTransaction; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1350,11 +1074,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'confirmTransaction'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('confirmTransaction(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public submitTransaction = { @@ -1365,19 +1090,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; - [destination, - value, - data - ] = BaseContract._formatABIDataItemList(inputAbi, [destination, - value, - data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, - value, - data - ]); - const encodedData = self._lookupEthersInterface('submitTransaction(address,uint256,bytes)').functions.submitTransaction.encode([destination, + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [destination, value, data ]); @@ -1405,15 +1118,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; - [destination, - value, - data - ] = BaseContract._formatABIDataItemList(inputAbi, [destination, - value, - data - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('submitTransaction(address,uint256,bytes)').functions.submitTransaction.encode([destination, + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [destination, value, data ]); @@ -1434,15 +1139,7 @@ export class AssetProxyOwnerContract extends BaseContract { data: string, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; - [destination, - value, - data - ] = BaseContract._formatABIDataItemList(inputAbi, [destination, - value, - data - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('submitTransaction(address,uint256,bytes)').functions.submitTransaction.encode([destination, + const abiEncodedTransactionData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [destination, value, data ]); @@ -1457,21 +1154,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'submitTransaction(address,uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [destination, - value, - data - ] = BaseContract._formatABIDataItemList(inputAbi, [destination, - value, - data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, - value, - data - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.submitTransaction; - const encodedData = ethersFunction.encode([destination, + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [destination, value, data ]); @@ -1485,11 +1168,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'submitTransaction'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('submitTransaction(address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public confirmationTimes = { @@ -1500,15 +1184,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'confirmationTimes(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmationTimes; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('confirmationTimes(uint256)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1520,11 +1196,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'confirmationTimes'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('confirmationTimes(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public MAX_OWNER_COUNT = { @@ -1534,12 +1211,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'MAX_OWNER_COUNT()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.MAX_OWNER_COUNT; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('MAX_OWNER_COUNT()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -1550,11 +1222,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'MAX_OWNER_COUNT'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('MAX_OWNER_COUNT()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public required = { @@ -1564,12 +1237,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'required()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.required; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('required()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -1580,11 +1248,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'required'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('required()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public replaceOwner = { @@ -1594,16 +1263,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; - [owner, - newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner, - newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, - newOwner - ]); - const encodedData = self._lookupEthersInterface('replaceOwner(address,address)').functions.replaceOwner.encode([owner, + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [owner, newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1628,13 +1288,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; - [owner, - newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner, - newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('replaceOwner(address,address)').functions.replaceOwner.encode([owner, + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [owner, newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1653,13 +1307,7 @@ export class AssetProxyOwnerContract extends BaseContract { newOwner: string, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; - [owner, - newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner, - newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('replaceOwner(address,address)').functions.replaceOwner.encode([owner, + const abiEncodedTransactionData = self._strictEncodeArguments('replaceOwner(address,address)', [owner, newOwner ]); return abiEncodedTransactionData; @@ -1672,18 +1320,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'replaceOwner(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [owner, - newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [owner, - newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, - newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.replaceOwner; - const encodedData = ethersFunction.encode([owner, + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [owner, newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1696,11 +1333,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'replaceOwner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('replaceOwner(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public executeTransaction = { @@ -1709,13 +1347,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const encodedData = self._lookupEthersInterface('executeTransaction(uint256)').functions.executeTransaction.encode([transactionId + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1737,11 +1369,7 @@ export class AssetProxyOwnerContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('executeTransaction(uint256)').functions.executeTransaction.encode([transactionId + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1758,11 +1386,7 @@ export class AssetProxyOwnerContract extends BaseContract { transactionId: BigNumber, ): string { const self = this as any as AssetProxyOwnerContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('executeTransaction(uint256)').functions.executeTransaction.encode([transactionId + const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId ]); return abiEncodedTransactionData; }, @@ -1773,15 +1397,7 @@ export class AssetProxyOwnerContract extends BaseContract { ): Promise<void > { const self = this as any as AssetProxyOwnerContract; - const functionSignature = 'executeTransaction(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [transactionId - ] = BaseContract._formatABIDataItemList(inputAbi, [transactionId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.executeTransaction; - const encodedData = ethersFunction.encode([transactionId + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1793,11 +1409,12 @@ export class AssetProxyOwnerContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'executeTransaction'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('executeTransaction(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -1871,7 +1488,7 @@ _secondsTimeLocked } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('AssetProxyOwner', 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-wrappers/src/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts index 3995c6d87..cab09c4d2 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -43,12 +43,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'name()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('name()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -59,11 +54,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public approve = { @@ -73,16 +69,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -107,13 +94,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -132,13 +113,7 @@ export class DummyERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); return abiEncodedTransactionData; @@ -151,18 +126,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -175,11 +139,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public totalSupply = { @@ -189,12 +154,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'totalSupply()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('totalSupply()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -205,11 +165,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -220,19 +181,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -260,15 +209,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -289,15 +230,7 @@ export class DummyERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -312,21 +245,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -340,11 +259,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public decimals = { @@ -354,12 +274,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'decimals()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.decimals; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('decimals()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -370,11 +285,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'decimals'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -385,15 +301,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([_owner + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -405,11 +313,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -419,12 +328,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -435,11 +339,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public symbol = { @@ -449,12 +354,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'symbol()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('symbol()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -465,11 +365,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public mint = { @@ -478,13 +379,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('mint(uint256)').inputs; - [_value - ] = BaseContract._formatABIDataItemList(inputAbi, [_value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_value - ]); - const encodedData = self._lookupEthersInterface('mint(uint256)').functions.mint.encode([_value + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -506,11 +401,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('mint(uint256)').inputs; - [_value - ] = BaseContract._formatABIDataItemList(inputAbi, [_value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('mint(uint256)').functions.mint.encode([_value + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -527,11 +418,7 @@ export class DummyERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('mint(uint256)').inputs; - [_value - ] = BaseContract._formatABIDataItemList(inputAbi, [_value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('mint(uint256)').functions.mint.encode([_value + const abiEncodedTransactionData = self._strictEncodeArguments('mint(uint256)', [_value ]); return abiEncodedTransactionData; }, @@ -542,15 +429,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'mint(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_value - ] = BaseContract._formatABIDataItemList(inputAbi, [_value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.mint; - const encodedData = ethersFunction.encode([_value + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -562,11 +441,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'mint'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('mint(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transfer = { @@ -576,16 +456,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -610,13 +481,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -635,13 +500,7 @@ export class DummyERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); return abiEncodedTransactionData; @@ -654,18 +513,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'transfer(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer; - const encodedData = ethersFunction.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -678,11 +526,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public allowance = { @@ -694,18 +543,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'allowance(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _spender - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _spender - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _spender - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner, _spender ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -718,11 +556,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public setBalance = { @@ -732,16 +571,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; - [_target, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_target, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_target, - _value - ]); - const encodedData = self._lookupEthersInterface('setBalance(address,uint256)').functions.setBalance.encode([_target, + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [_target, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -766,13 +596,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; - [_target, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_target, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('setBalance(address,uint256)').functions.setBalance.encode([_target, + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [_target, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -791,13 +615,7 @@ export class DummyERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; - [_target, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_target, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('setBalance(address,uint256)').functions.setBalance.encode([_target, + const abiEncodedTransactionData = self._strictEncodeArguments('setBalance(address,uint256)', [_target, _value ]); return abiEncodedTransactionData; @@ -810,18 +628,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'setBalance(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_target, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_target, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_target, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setBalance; - const encodedData = ethersFunction.encode([_target, + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [_target, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -834,11 +641,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'setBalance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('setBalance(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -847,13 +655,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -875,11 +677,7 @@ export class DummyERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -896,11 +694,7 @@ export class DummyERC20TokenContract extends BaseContract { newOwner: string, ): string { const self = this as any as DummyERC20TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -911,15 +705,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -931,11 +717,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public MAX_MINT_AMOUNT = { @@ -945,12 +732,7 @@ export class DummyERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC20TokenContract; - const functionSignature = 'MAX_MINT_AMOUNT()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.MAX_MINT_AMOUNT; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('MAX_MINT_AMOUNT()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -961,11 +743,12 @@ export class DummyERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'MAX_MINT_AMOUNT'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('MAX_MINT_AMOUNT()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -1039,7 +822,7 @@ _totalSupply } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('DummyERC20Token', 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-wrappers/src/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts index a7af2d158..9cb54442b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -51,12 +51,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'name()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('name()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -67,11 +62,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getApproved = { @@ -82,15 +78,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'getApproved(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getApproved; - const encodedData = ethersFunction.encode([_tokenId + const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -102,11 +90,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getApproved'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public approve = { @@ -116,16 +105,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -150,13 +130,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -175,13 +149,7 @@ export class DummyERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); return abiEncodedTransactionData; @@ -194,18 +162,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -218,11 +175,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -233,19 +191,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -273,15 +219,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -302,15 +240,7 @@ export class DummyERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -325,21 +255,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -353,11 +269,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public mint = { @@ -367,16 +284,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('mint(address,uint256)').inputs; - [_to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('mint(address,uint256)').functions.mint.encode([_to, + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -401,13 +309,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('mint(address,uint256)').inputs; - [_to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('mint(address,uint256)').functions.mint.encode([_to, + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -426,13 +328,7 @@ export class DummyERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('mint(address,uint256)').inputs; - [_to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('mint(address,uint256)').functions.mint.encode([_to, + const abiEncodedTransactionData = self._strictEncodeArguments('mint(address,uint256)', [_to, _tokenId ]); return abiEncodedTransactionData; @@ -445,18 +341,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'mint(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.mint; - const encodedData = ethersFunction.encode([_to, + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to, _tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -469,11 +354,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'mint'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('mint(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public safeTransferFrom1 = { @@ -484,19 +370,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -524,15 +398,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -553,15 +419,7 @@ export class DummyERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -576,21 +434,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'safeTransferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -604,11 +448,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public ownerOf = { @@ -619,15 +464,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'ownerOf(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.ownerOf; - const encodedData = ethersFunction.encode([_tokenId + const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -639,11 +476,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'ownerOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -654,15 +492,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([_owner + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -674,11 +504,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -688,12 +519,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -704,11 +530,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public symbol = { @@ -718,12 +545,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'symbol()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('symbol()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -734,11 +556,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public burn = { @@ -748,16 +571,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('burn(address,uint256)').inputs; - [_owner, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('burn(address,uint256)').functions.burn.encode([_owner, + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -782,13 +596,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('burn(address,uint256)').inputs; - [_owner, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('burn(address,uint256)').functions.burn.encode([_owner, + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -807,13 +615,7 @@ export class DummyERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('burn(address,uint256)').inputs; - [_owner, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('burn(address,uint256)').functions.burn.encode([_owner, + const abiEncodedTransactionData = self._strictEncodeArguments('burn(address,uint256)', [_owner, _tokenId ]); return abiEncodedTransactionData; @@ -826,18 +628,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'burn(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.burn; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner, _tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -850,11 +641,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'burn'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('burn(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public setApprovalForAll = { @@ -864,16 +656,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator, - _approved - ]); - const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -898,13 +681,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -923,13 +700,7 @@ export class DummyERC721TokenContract extends BaseContract { _approved: boolean, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); return abiEncodedTransactionData; @@ -942,18 +713,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'setApprovalForAll(address,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator, - _approved - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setApprovalForAll; - const encodedData = ethersFunction.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -966,11 +726,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'setApprovalForAll'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public safeTransferFrom2 = { @@ -982,22 +743,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId, - _data - ]); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -1028,17 +774,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -1061,17 +797,7 @@ export class DummyERC721TokenContract extends BaseContract { _data: string, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -1088,24 +814,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'safeTransferFrom(address,address,uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId, - _data - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -1120,11 +829,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isApprovedForAll = { @@ -1136,18 +846,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'isApprovedForAll(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _operator - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _operator - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _operator - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isApprovedForAll; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [_owner, _operator ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1160,11 +859,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isApprovedForAll'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -1173,13 +873,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1201,11 +895,7 @@ export class DummyERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1222,11 +912,7 @@ export class DummyERC721TokenContract extends BaseContract { newOwner: string, ): string { const self = this as any as DummyERC721TokenContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -1237,15 +923,7 @@ export class DummyERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as DummyERC721TokenContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1257,11 +935,12 @@ export class DummyERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -1321,7 +1000,7 @@ _symbol } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('DummyERC721Token', 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-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts index 90e233756..9be95af65 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts @@ -21,13 +21,7 @@ export class DutchAuctionContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order - ]); - const encodedData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order + const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -49,11 +43,7 @@ export class DutchAuctionContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order + const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -70,11 +60,7 @@ export class DutchAuctionContract extends BaseContract { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, ): string { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order + const abiEncodedTransactionData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); return abiEncodedTransactionData; }, @@ -85,15 +71,7 @@ export class DutchAuctionContract extends BaseContract { ): Promise<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber} > { const self = this as any as DutchAuctionContract; - const functionSignature = 'getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuctionDetails; - const encodedData = ethersFunction.encode([order + const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -105,11 +83,12 @@ export class DutchAuctionContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getAuctionDetails'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public matchOrders = { @@ -121,22 +100,7 @@ export class DutchAuctionContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [buyOrder, - sellOrder, - buySignature, - sellSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ]); - const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder, sellOrder, buySignature, sellSignature @@ -167,17 +131,7 @@ export class DutchAuctionContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [buyOrder, - sellOrder, - buySignature, - sellSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder, sellOrder, buySignature, sellSignature @@ -200,17 +154,7 @@ export class DutchAuctionContract extends BaseContract { sellSignature: string, ): string { const self = this as any as DutchAuctionContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [buyOrder, - sellOrder, - buySignature, - sellSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder, + const abiEncodedTransactionData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder, sellOrder, buySignature, sellSignature @@ -227,24 +171,7 @@ export class DutchAuctionContract extends BaseContract { ): Promise<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber} > { const self = this as any as DutchAuctionContract; - const functionSignature = 'matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [buyOrder, - sellOrder, - buySignature, - sellSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [buyOrder, - sellOrder, - buySignature, - sellSignature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.matchOrders; - const encodedData = ethersFunction.encode([buyOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder, sellOrder, buySignature, sellSignature @@ -259,11 +186,12 @@ export class DutchAuctionContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'matchOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -316,7 +244,7 @@ export class DutchAuctionContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('DutchAuction', 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-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts index 474472e43..1d53df6b8 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -40,13 +40,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -68,11 +62,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -89,11 +79,7 @@ export class ERC20ProxyContract extends BaseContract { target: string, ): string { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); return abiEncodedTransactionData; }, @@ -104,15 +90,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'addAuthorizedAddress(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addAuthorizedAddress; - const encodedData = ethersFunction.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -124,11 +102,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'addAuthorizedAddress'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public authorities = { @@ -139,15 +118,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'authorities(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorities; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -159,11 +130,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'authorities'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public removeAuthorizedAddress = { @@ -172,13 +144,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -200,11 +166,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -221,11 +183,7 @@ export class ERC20ProxyContract extends BaseContract { target: string, ): string { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); return abiEncodedTransactionData; }, @@ -236,15 +194,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'removeAuthorizedAddress(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddress; - const encodedData = ethersFunction.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -256,11 +206,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddress'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -270,12 +221,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -286,11 +232,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public removeAuthorizedAddressAtIndex = { @@ -300,16 +247,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - index - ]); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -334,13 +272,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -359,13 +291,7 @@ export class ERC20ProxyContract extends BaseContract { index: BigNumber, ): string { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); return abiEncodedTransactionData; @@ -378,18 +304,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'removeAuthorizedAddressAtIndex(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - index - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddressAtIndex; - const encodedData = ethersFunction.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -402,11 +317,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddressAtIndex'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getProxyId = { @@ -416,12 +332,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'getProxyId()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getProxyId; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('getProxyId()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -432,11 +343,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getProxyId'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public authorized = { @@ -447,15 +359,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'authorized(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorized; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -467,11 +371,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'authorized'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getAuthorizedAddresses = { @@ -481,12 +386,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<string[] > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'getAuthorizedAddresses()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuthorizedAddresses; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -497,11 +397,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getAuthorizedAddresses'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -510,13 +411,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -538,11 +433,7 @@ export class ERC20ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -559,11 +450,7 @@ export class ERC20ProxyContract extends BaseContract { newOwner: string, ): string { const self = this as any as ERC20ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -574,15 +461,7 @@ export class ERC20ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC20ProxyContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -594,11 +473,12 @@ export class ERC20ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -644,7 +524,7 @@ export class ERC20ProxyContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('ERC20Proxy', 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-wrappers/src/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts index ab208cbf5..5070111e1 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -43,16 +43,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -77,13 +68,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -102,13 +87,7 @@ export class ERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); return abiEncodedTransactionData; @@ -121,18 +100,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC20TokenContract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -145,11 +113,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public totalSupply = { @@ -159,12 +128,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ERC20TokenContract; - const functionSignature = 'totalSupply()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('totalSupply()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -175,11 +139,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -190,19 +155,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -230,15 +183,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -259,15 +204,7 @@ export class ERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -282,21 +219,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC20TokenContract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -310,11 +233,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -325,15 +249,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ERC20TokenContract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([_owner + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -345,11 +261,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transfer = { @@ -359,16 +276,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -393,13 +301,7 @@ export class ERC20TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -418,13 +320,7 @@ export class ERC20TokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ERC20TokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); return abiEncodedTransactionData; @@ -437,18 +333,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC20TokenContract; - const functionSignature = 'transfer(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer; - const encodedData = ethersFunction.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -461,11 +346,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public allowance = { @@ -477,18 +363,7 @@ export class ERC20TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ERC20TokenContract; - const functionSignature = 'allowance(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _spender - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _spender - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _spender - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner, _spender ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -501,11 +376,12 @@ export class ERC20TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -551,7 +427,7 @@ export class ERC20TokenContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('ERC20Token', 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-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts index f9730a072..5a9fcc7d1 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -40,13 +40,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -68,11 +62,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -89,11 +79,7 @@ export class ERC721ProxyContract extends BaseContract { target: string, ): string { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); return abiEncodedTransactionData; }, @@ -104,15 +90,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'addAuthorizedAddress(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addAuthorizedAddress; - const encodedData = ethersFunction.encode([target + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -124,11 +102,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'addAuthorizedAddress'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public authorities = { @@ -139,15 +118,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'authorities(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorities; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -159,11 +130,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'authorities'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public removeAuthorizedAddress = { @@ -172,13 +144,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -200,11 +166,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -221,11 +183,7 @@ export class ERC721ProxyContract extends BaseContract { target: string, ): string { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); return abiEncodedTransactionData; }, @@ -236,15 +194,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'removeAuthorizedAddress(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target - ] = BaseContract._formatABIDataItemList(inputAbi, [target - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddress; - const encodedData = ethersFunction.encode([target + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -256,11 +206,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddress'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -270,12 +221,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -286,11 +232,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public removeAuthorizedAddressAtIndex = { @@ -300,16 +247,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - index - ]); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -334,13 +272,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -359,13 +291,7 @@ export class ERC721ProxyContract extends BaseContract { index: BigNumber, ): string { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target, + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); return abiEncodedTransactionData; @@ -378,18 +304,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'removeAuthorizedAddressAtIndex(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target, - index - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - index - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - index - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddressAtIndex; - const encodedData = ethersFunction.encode([target, + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, index ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -402,11 +317,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddressAtIndex'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getProxyId = { @@ -416,12 +332,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<string > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'getProxyId()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getProxyId; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('getProxyId()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -432,11 +343,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getProxyId'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public authorized = { @@ -447,15 +359,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'authorized(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorized; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -467,11 +371,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'authorized'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getAuthorizedAddresses = { @@ -481,12 +386,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<string[] > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'getAuthorizedAddresses()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuthorizedAddresses; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -497,11 +397,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getAuthorizedAddresses'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -510,13 +411,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -538,11 +433,7 @@ export class ERC721ProxyContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -559,11 +450,7 @@ export class ERC721ProxyContract extends BaseContract { newOwner: string, ): string { const self = this as any as ERC721ProxyContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -574,15 +461,7 @@ export class ERC721ProxyContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721ProxyContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -594,11 +473,12 @@ export class ERC721ProxyContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -644,7 +524,7 @@ export class ERC721ProxyContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('ERC721Proxy', 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-wrappers/src/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts index 251dfa5f9..aaae2ab76 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -52,15 +52,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as ERC721TokenContract; - const functionSignature = 'getApproved(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getApproved; - const encodedData = ethersFunction.encode([_tokenId + const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -72,11 +64,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getApproved'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public approve = { @@ -86,16 +79,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -120,13 +104,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -145,13 +123,7 @@ export class ERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); return abiEncodedTransactionData; @@ -164,18 +136,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721TokenContract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_approved, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_approved, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([_approved, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved, _tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -188,11 +149,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -203,19 +165,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -243,15 +193,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -272,15 +214,7 @@ export class ERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -295,21 +229,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721TokenContract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -323,11 +243,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public safeTransferFrom1 = { @@ -338,19 +259,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -378,15 +287,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -407,15 +308,7 @@ export class ERC721TokenContract extends BaseContract { _tokenId: BigNumber, ): string { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -430,21 +323,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721TokenContract; - const functionSignature = 'safeTransferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from, _to, _tokenId ]); @@ -458,11 +337,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public ownerOf = { @@ -473,15 +353,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<string > { const self = this as any as ERC721TokenContract; - const functionSignature = 'ownerOf(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.ownerOf; - const encodedData = ethersFunction.encode([_tokenId + const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -493,11 +365,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'ownerOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -508,15 +381,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ERC721TokenContract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([_owner + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -528,11 +393,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public setApprovalForAll = { @@ -542,16 +408,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator, - _approved - ]); - const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -576,13 +433,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -601,13 +452,7 @@ export class ERC721TokenContract extends BaseContract { _approved: boolean, ): string { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator, + const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); return abiEncodedTransactionData; @@ -620,18 +465,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721TokenContract; - const functionSignature = 'setApprovalForAll(address,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_operator, - _approved - ] = BaseContract._formatABIDataItemList(inputAbi, [_operator, - _approved - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator, - _approved - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setApprovalForAll; - const encodedData = ethersFunction.encode([_operator, + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator, _approved ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -644,11 +478,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'setApprovalForAll'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public safeTransferFrom2 = { @@ -660,22 +495,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId, - _data - ]); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -706,17 +526,7 @@ export class ERC721TokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -739,17 +549,7 @@ export class ERC721TokenContract extends BaseContract { _data: string, ): string { const self = this as any as ERC721TokenContract; - const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -766,24 +566,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<void > { const self = this as any as ERC721TokenContract; - const functionSignature = 'safeTransferFrom(address,address,uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _tokenId, - _data - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _tokenId, - _data - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _tokenId, - _data - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from, _to, _tokenId, _data @@ -798,11 +581,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isApprovedForAll = { @@ -814,18 +598,7 @@ export class ERC721TokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ERC721TokenContract; - const functionSignature = 'isApprovedForAll(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _operator - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _operator - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _operator - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isApprovedForAll; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [_owner, _operator ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -838,11 +611,12 @@ export class ERC721TokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isApprovedForAll'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -888,7 +662,7 @@ export class ERC721TokenContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('ERC721Token', 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-wrappers/src/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts index 11b5e7024..146fa7c2a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -78,15 +78,7 @@ export class ExchangeContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ExchangeContract; - const functionSignature = 'filled(bytes32)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.filled; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('filled(bytes32)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -98,11 +90,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'filled'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('filled(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public batchFillOrders = { @@ -113,19 +106,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const encodedData = self._lookupEthersInterface('batchFillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrders.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -153,15 +134,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('batchFillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrders.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -182,15 +155,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('batchFillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrders.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -205,21 +170,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'batchFillOrders(tuple[],uint256[],bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.batchFillOrders; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -233,11 +184,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'batchFillOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public cancelled = { @@ -248,15 +200,7 @@ export class ExchangeContract extends BaseContract { ): Promise<boolean > { const self = this as any as ExchangeContract; - const functionSignature = 'cancelled(bytes32)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.cancelled; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('cancelled(bytes32)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -268,11 +212,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'cancelled'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('cancelled(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public preSign = { @@ -283,19 +228,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('preSign(bytes32,address,bytes)').inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [hash, - signerAddress, - signature - ]); - const encodedData = self._lookupEthersInterface('preSign(bytes32,address,bytes)').functions.preSign.encode([hash, + const encodedData = self._strictEncodeArguments('preSign(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -323,15 +256,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('preSign(bytes32,address,bytes)').inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('preSign(bytes32,address,bytes)').functions.preSign.encode([hash, + const encodedData = self._strictEncodeArguments('preSign(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -352,15 +277,7 @@ export class ExchangeContract extends BaseContract { signature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('preSign(bytes32,address,bytes)').inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('preSign(bytes32,address,bytes)').functions.preSign.encode([hash, + const abiEncodedTransactionData = self._strictEncodeArguments('preSign(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -375,21 +292,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'preSign(bytes32,address,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [hash, - signerAddress, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.preSign; - const encodedData = ethersFunction.encode([hash, + const encodedData = self._strictEncodeArguments('preSign(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -403,11 +306,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'preSign'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('preSign(bytes32,address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public matchOrders = { @@ -419,22 +323,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [leftOrder, - rightOrder, - leftSignature, - rightSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ]); - const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([leftOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [leftOrder, rightOrder, leftSignature, rightSignature @@ -465,17 +354,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [leftOrder, - rightOrder, - leftSignature, - rightSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([leftOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [leftOrder, rightOrder, leftSignature, rightSignature @@ -498,17 +377,7 @@ export class ExchangeContract extends BaseContract { rightSignature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs; - [leftOrder, - rightOrder, - leftSignature, - rightSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([leftOrder, + const abiEncodedTransactionData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [leftOrder, rightOrder, leftSignature, rightSignature @@ -525,24 +394,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [leftOrder, - rightOrder, - leftSignature, - rightSignature - ] = BaseContract._formatABIDataItemList(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [leftOrder, - rightOrder, - leftSignature, - rightSignature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.matchOrders; - const encodedData = ethersFunction.encode([leftOrder, + const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [leftOrder, rightOrder, leftSignature, rightSignature @@ -557,11 +409,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'matchOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public fillOrderNoThrow = { @@ -572,19 +425,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const encodedData = self._lookupEthersInterface('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrderNoThrow.encode([order, + const encodedData = self._strictEncodeArguments('fillOrderNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -612,15 +453,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrderNoThrow.encode([order, + const encodedData = self._strictEncodeArguments('fillOrderNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -641,15 +474,7 @@ export class ExchangeContract extends BaseContract { signature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrderNoThrow.encode([order, + const abiEncodedTransactionData = self._strictEncodeArguments('fillOrderNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -664,21 +489,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'fillOrderNoThrow({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.fillOrderNoThrow; - const encodedData = ethersFunction.encode([order, + const encodedData = self._strictEncodeArguments('fillOrderNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -692,11 +503,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'fillOrderNoThrow'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('fillOrderNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public assetProxies = { @@ -707,15 +519,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'assetProxies(bytes4)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.assetProxies; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('assetProxies(bytes4)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -727,11 +531,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'assetProxies'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('assetProxies(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public batchCancelOrders = { @@ -740,13 +545,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchCancelOrders(tuple[])').inputs; - [orders - ] = BaseContract._formatABIDataItemList(inputAbi, [orders - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders - ]); - const encodedData = self._lookupEthersInterface('batchCancelOrders(tuple[])').functions.batchCancelOrders.encode([orders + const encodedData = self._strictEncodeArguments('batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])', [orders ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -768,11 +567,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchCancelOrders(tuple[])').inputs; - [orders - ] = BaseContract._formatABIDataItemList(inputAbi, [orders - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('batchCancelOrders(tuple[])').functions.batchCancelOrders.encode([orders + const encodedData = self._strictEncodeArguments('batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])', [orders ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -789,11 +584,7 @@ export class ExchangeContract extends BaseContract { orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchCancelOrders(tuple[])').inputs; - [orders - ] = BaseContract._formatABIDataItemList(inputAbi, [orders - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('batchCancelOrders(tuple[])').functions.batchCancelOrders.encode([orders + const abiEncodedTransactionData = self._strictEncodeArguments('batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])', [orders ]); return abiEncodedTransactionData; }, @@ -804,15 +595,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'batchCancelOrders(tuple[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders - ] = BaseContract._formatABIDataItemList(inputAbi, [orders - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.batchCancelOrders; - const encodedData = ethersFunction.encode([orders + const encodedData = self._strictEncodeArguments('batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])', [orders ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -824,11 +607,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'batchCancelOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public batchFillOrKillOrders = { @@ -839,19 +623,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrKillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const encodedData = self._lookupEthersInterface('batchFillOrKillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrKillOrders.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -879,15 +651,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrKillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('batchFillOrKillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrKillOrders.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -908,15 +672,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrKillOrders(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('batchFillOrKillOrders(tuple[],uint256[],bytes[])').functions.batchFillOrKillOrders.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -931,21 +687,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'batchFillOrKillOrders(tuple[],uint256[],bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.batchFillOrKillOrders; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -959,11 +701,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'batchFillOrKillOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public cancelOrdersUpTo = { @@ -972,13 +715,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrdersUpTo(uint256)').inputs; - [targetOrderEpoch - ] = BaseContract._formatABIDataItemList(inputAbi, [targetOrderEpoch - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [targetOrderEpoch - ]); - const encodedData = self._lookupEthersInterface('cancelOrdersUpTo(uint256)').functions.cancelOrdersUpTo.encode([targetOrderEpoch + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1000,11 +737,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrdersUpTo(uint256)').inputs; - [targetOrderEpoch - ] = BaseContract._formatABIDataItemList(inputAbi, [targetOrderEpoch - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('cancelOrdersUpTo(uint256)').functions.cancelOrdersUpTo.encode([targetOrderEpoch + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1021,11 +754,7 @@ export class ExchangeContract extends BaseContract { targetOrderEpoch: BigNumber, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrdersUpTo(uint256)').inputs; - [targetOrderEpoch - ] = BaseContract._formatABIDataItemList(inputAbi, [targetOrderEpoch - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('cancelOrdersUpTo(uint256)').functions.cancelOrdersUpTo.encode([targetOrderEpoch + const abiEncodedTransactionData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch ]); return abiEncodedTransactionData; }, @@ -1036,15 +765,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'cancelOrdersUpTo(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [targetOrderEpoch - ] = BaseContract._formatABIDataItemList(inputAbi, [targetOrderEpoch - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [targetOrderEpoch - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.cancelOrdersUpTo; - const encodedData = ethersFunction.encode([targetOrderEpoch + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1056,11 +777,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'cancelOrdersUpTo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('cancelOrdersUpTo(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public batchFillOrdersNoThrow = { @@ -1071,19 +793,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const encodedData = self._lookupEthersInterface('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').functions.batchFillOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -1111,15 +821,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').functions.batchFillOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -1140,15 +842,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('batchFillOrdersNoThrow(tuple[],uint256[],bytes[])').functions.batchFillOrdersNoThrow.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -1163,21 +857,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'batchFillOrdersNoThrow(tuple[],uint256[],bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAssetFillAmounts, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmounts, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.batchFillOrdersNoThrow; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])', [orders, takerAssetFillAmounts, signatures ]); @@ -1191,11 +871,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'batchFillOrdersNoThrow'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getAssetProxy = { @@ -1206,15 +887,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'getAssetProxy(bytes4)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [assetProxyId - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxyId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetProxyId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAssetProxy; - const encodedData = ethersFunction.encode([assetProxyId + const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1226,11 +899,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getAssetProxy'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transactions = { @@ -1241,15 +915,7 @@ export class ExchangeContract extends BaseContract { ): Promise<boolean > { const self = this as any as ExchangeContract; - const functionSignature = 'transactions(bytes32)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactions; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('transactions(bytes32)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1261,11 +927,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transactions'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transactions(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public fillOrKillOrder = { @@ -1276,19 +943,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const encodedData = self._lookupEthersInterface('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrKillOrder.encode([order, + const encodedData = self._strictEncodeArguments('fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -1316,15 +971,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrKillOrder.encode([order, + const encodedData = self._strictEncodeArguments('fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -1345,15 +992,7 @@ export class ExchangeContract extends BaseContract { signature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrKillOrder.encode([order, + const abiEncodedTransactionData = self._strictEncodeArguments('fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -1368,21 +1007,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'fillOrKillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.fillOrKillOrder; - const encodedData = ethersFunction.encode([order, + const encodedData = self._strictEncodeArguments('fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -1396,11 +1021,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'fillOrKillOrder'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public setSignatureValidatorApproval = { @@ -1410,16 +1036,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('setSignatureValidatorApproval(address,bool)').inputs; - [validatorAddress, - approval - ] = BaseContract._formatABIDataItemList(inputAbi, [validatorAddress, - approval - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [validatorAddress, - approval - ]); - const encodedData = self._lookupEthersInterface('setSignatureValidatorApproval(address,bool)').functions.setSignatureValidatorApproval.encode([validatorAddress, + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [validatorAddress, approval ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1444,13 +1061,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('setSignatureValidatorApproval(address,bool)').inputs; - [validatorAddress, - approval - ] = BaseContract._formatABIDataItemList(inputAbi, [validatorAddress, - approval - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('setSignatureValidatorApproval(address,bool)').functions.setSignatureValidatorApproval.encode([validatorAddress, + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [validatorAddress, approval ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1469,13 +1080,7 @@ export class ExchangeContract extends BaseContract { approval: boolean, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('setSignatureValidatorApproval(address,bool)').inputs; - [validatorAddress, - approval - ] = BaseContract._formatABIDataItemList(inputAbi, [validatorAddress, - approval - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('setSignatureValidatorApproval(address,bool)').functions.setSignatureValidatorApproval.encode([validatorAddress, + const abiEncodedTransactionData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [validatorAddress, approval ]); return abiEncodedTransactionData; @@ -1488,18 +1093,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'setSignatureValidatorApproval(address,bool)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [validatorAddress, - approval - ] = BaseContract._formatABIDataItemList(inputAbi, [validatorAddress, - approval - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [validatorAddress, - approval - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setSignatureValidatorApproval; - const encodedData = ethersFunction.encode([validatorAddress, + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [validatorAddress, approval ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1512,11 +1106,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'setSignatureValidatorApproval'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('setSignatureValidatorApproval(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public allowedValidators = { @@ -1528,18 +1123,7 @@ export class ExchangeContract extends BaseContract { ): Promise<boolean > { const self = this as any as ExchangeContract; - const functionSignature = 'allowedValidators(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0, - index_1 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0, - index_1 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, - index_1 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowedValidators; - const encodedData = ethersFunction.encode([index_0, + const encodedData = self._strictEncodeArguments('allowedValidators(address,address)', [index_0, index_1 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1552,11 +1136,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'allowedValidators'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('allowedValidators(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public marketSellOrders = { @@ -1567,19 +1152,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrders(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmount, - signatures - ]); - const encodedData = self._lookupEthersInterface('marketSellOrders(tuple[],uint256,bytes[])').functions.marketSellOrders.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -1607,15 +1180,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrders(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketSellOrders(tuple[],uint256,bytes[])').functions.marketSellOrders.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -1636,15 +1201,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrders(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketSellOrders(tuple[],uint256,bytes[])').functions.marketSellOrders.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketSellOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -1659,21 +1216,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'marketSellOrders(tuple[],uint256,bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmount, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketSellOrders; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -1687,11 +1230,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketSellOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('marketSellOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getOrdersInfo = { @@ -1702,15 +1246,7 @@ export class ExchangeContract extends BaseContract { ): Promise<Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}> > { const self = this as any as ExchangeContract; - const functionSignature = 'getOrdersInfo(tuple[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders - ] = BaseContract._formatABIDataItemList(inputAbi, [orders - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrdersInfo; - const encodedData = ethersFunction.encode([orders + const encodedData = self._strictEncodeArguments('getOrdersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])', [orders ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -1722,11 +1258,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getOrdersInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getOrdersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}> + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public preSigned = { @@ -1738,18 +1275,7 @@ export class ExchangeContract extends BaseContract { ): Promise<boolean > { const self = this as any as ExchangeContract; - const functionSignature = 'preSigned(bytes32,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0, - index_1 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0, - index_1 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, - index_1 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.preSigned; - const encodedData = ethersFunction.encode([index_0, + const encodedData = self._strictEncodeArguments('preSigned(bytes32,address)', [index_0, index_1 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -1762,11 +1288,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'preSigned'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('preSigned(bytes32,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -1776,12 +1303,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -1792,11 +1314,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public isValidSignature = { @@ -1809,21 +1332,7 @@ export class ExchangeContract extends BaseContract { ): Promise<boolean > { const self = this as any as ExchangeContract; - const functionSignature = 'isValidSignature(bytes32,address,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [hash, - signerAddress, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isValidSignature; - const encodedData = ethersFunction.encode([hash, + const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -1837,11 +1346,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isValidSignature'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public marketBuyOrdersNoThrow = { @@ -1852,19 +1362,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures - ]); - const encodedData = self._lookupEthersInterface('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketBuyOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -1892,15 +1390,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketBuyOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -1921,15 +1411,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketBuyOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketBuyOrdersNoThrow.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -1944,21 +1426,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'marketBuyOrdersNoThrow(tuple[],uint256,bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketBuyOrdersNoThrow; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -1972,11 +1440,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketBuyOrdersNoThrow'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public fillOrder = { @@ -1987,19 +1456,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const encodedData = self._lookupEthersInterface('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrder.encode([order, + const encodedData = self._strictEncodeArguments('fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -2027,15 +1484,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrder.encode([order, + const encodedData = self._strictEncodeArguments('fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -2056,15 +1505,7 @@ export class ExchangeContract extends BaseContract { signature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)').functions.fillOrder.encode([order, + const abiEncodedTransactionData = self._strictEncodeArguments('fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -2079,21 +1520,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'fillOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},uint256,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order, - takerAssetFillAmount, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAssetFillAmount, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAssetFillAmount, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.fillOrder; - const encodedData = ethersFunction.encode([order, + const encodedData = self._strictEncodeArguments('fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)', [order, takerAssetFillAmount, signature ]); @@ -2107,11 +1534,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'fillOrder'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public executeTransaction = { @@ -2123,22 +1551,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256,address,bytes,bytes)').inputs; - [salt, - signerAddress, - data, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [salt, - signerAddress, - data, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [salt, - signerAddress, - data, - signature - ]); - const encodedData = self._lookupEthersInterface('executeTransaction(uint256,address,bytes,bytes)').functions.executeTransaction.encode([salt, + const encodedData = self._strictEncodeArguments('executeTransaction(uint256,address,bytes,bytes)', [salt, signerAddress, data, signature @@ -2169,17 +1582,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256,address,bytes,bytes)').inputs; - [salt, - signerAddress, - data, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [salt, - signerAddress, - data, - signature - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('executeTransaction(uint256,address,bytes,bytes)').functions.executeTransaction.encode([salt, + const encodedData = self._strictEncodeArguments('executeTransaction(uint256,address,bytes,bytes)', [salt, signerAddress, data, signature @@ -2202,17 +1605,7 @@ export class ExchangeContract extends BaseContract { signature: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('executeTransaction(uint256,address,bytes,bytes)').inputs; - [salt, - signerAddress, - data, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [salt, - signerAddress, - data, - signature - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('executeTransaction(uint256,address,bytes,bytes)').functions.executeTransaction.encode([salt, + const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction(uint256,address,bytes,bytes)', [salt, signerAddress, data, signature @@ -2229,24 +1622,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'executeTransaction(uint256,address,bytes,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [salt, - signerAddress, - data, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [salt, - signerAddress, - data, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [salt, - signerAddress, - data, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.executeTransaction; - const encodedData = ethersFunction.encode([salt, + const encodedData = self._strictEncodeArguments('executeTransaction(uint256,address,bytes,bytes)', [salt, signerAddress, data, signature @@ -2261,11 +1637,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'executeTransaction'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('executeTransaction(uint256,address,bytes,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public registerAssetProxy = { @@ -2274,13 +1651,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address)').inputs; - [assetProxy - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetProxy - ]); - const encodedData = self._lookupEthersInterface('registerAssetProxy(address)').functions.registerAssetProxy.encode([assetProxy + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2302,11 +1673,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address)').inputs; - [assetProxy - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('registerAssetProxy(address)').functions.registerAssetProxy.encode([assetProxy + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2323,11 +1690,7 @@ export class ExchangeContract extends BaseContract { assetProxy: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('registerAssetProxy(address)').inputs; - [assetProxy - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('registerAssetProxy(address)').functions.registerAssetProxy.encode([assetProxy + const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy ]); return abiEncodedTransactionData; }, @@ -2338,15 +1701,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'registerAssetProxy(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [assetProxy - ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetProxy - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.registerAssetProxy; - const encodedData = ethersFunction.encode([assetProxy + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2358,11 +1713,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'registerAssetProxy'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getOrderInfo = { @@ -2373,15 +1729,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'getOrderInfo({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrderInfo; - const encodedData = ethersFunction.encode([order + const encodedData = self._strictEncodeArguments('getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2393,11 +1741,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getOrderInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public cancelOrder = { @@ -2406,13 +1755,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order - ]); - const encodedData = self._lookupEthersInterface('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.cancelOrder.encode([order + const encodedData = self._strictEncodeArguments('cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2434,11 +1777,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.cancelOrder.encode([order + const encodedData = self._strictEncodeArguments('cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2455,11 +1794,7 @@ export class ExchangeContract extends BaseContract { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.cancelOrder.encode([order + const abiEncodedTransactionData = self._strictEncodeArguments('cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); return abiEncodedTransactionData; }, @@ -2470,15 +1805,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'cancelOrder({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order - ] = BaseContract._formatABIDataItemList(inputAbi, [order - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.cancelOrder; - const encodedData = ethersFunction.encode([order + const encodedData = self._strictEncodeArguments('cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2490,11 +1817,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'cancelOrder'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public orderEpoch = { @@ -2506,18 +1834,7 @@ export class ExchangeContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ExchangeContract; - const functionSignature = 'orderEpoch(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0, - index_1 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0, - index_1 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, - index_1 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.orderEpoch; - const encodedData = ethersFunction.encode([index_0, + const encodedData = self._strictEncodeArguments('orderEpoch(address,address)', [index_0, index_1 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -2530,11 +1847,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'orderEpoch'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('orderEpoch(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public ZRX_ASSET_DATA = { @@ -2544,12 +1862,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'ZRX_ASSET_DATA()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.ZRX_ASSET_DATA; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('ZRX_ASSET_DATA()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -2560,11 +1873,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'ZRX_ASSET_DATA'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('ZRX_ASSET_DATA()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public marketSellOrdersNoThrow = { @@ -2575,19 +1889,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmount, - signatures - ]); - const encodedData = self._lookupEthersInterface('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketSellOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -2615,15 +1917,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketSellOrdersNoThrow.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -2644,15 +1938,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketSellOrdersNoThrow(tuple[],uint256,bytes[])').functions.marketSellOrdersNoThrow.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -2667,21 +1953,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'marketSellOrdersNoThrow(tuple[],uint256,bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAssetFillAmount, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketSellOrdersNoThrow; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, takerAssetFillAmount, signatures ]); @@ -2695,11 +1967,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketSellOrdersNoThrow'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public EIP712_DOMAIN_HASH = { @@ -2709,12 +1982,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'EIP712_DOMAIN_HASH()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.EIP712_DOMAIN_HASH; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('EIP712_DOMAIN_HASH()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -2725,11 +1993,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'EIP712_DOMAIN_HASH'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('EIP712_DOMAIN_HASH()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public marketBuyOrders = { @@ -2740,19 +2009,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrders(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures - ]); - const encodedData = self._lookupEthersInterface('marketBuyOrders(tuple[],uint256,bytes[])').functions.marketBuyOrders.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -2780,15 +2037,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrders(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketBuyOrders(tuple[],uint256,bytes[])').functions.marketBuyOrders.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -2809,15 +2058,7 @@ export class ExchangeContract extends BaseContract { signatures: string[], ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('marketBuyOrders(tuple[],uint256,bytes[])').inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketBuyOrders(tuple[],uint256,bytes[])').functions.marketBuyOrders.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketBuyOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -2832,21 +2073,7 @@ export class ExchangeContract extends BaseContract { ): Promise<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} > { const self = this as any as ExchangeContract; - const functionSignature = 'marketBuyOrders(tuple[],uint256,bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - makerAssetFillAmount, - signatures - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketBuyOrders; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])', [orders, makerAssetFillAmount, signatures ]); @@ -2860,11 +2087,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketBuyOrders'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('marketBuyOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public currentContextAddress = { @@ -2874,12 +2102,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'currentContextAddress()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.currentContextAddress; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('currentContextAddress()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -2890,11 +2113,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'currentContextAddress'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('currentContextAddress()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -2903,13 +2127,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2931,11 +2149,7 @@ export class ExchangeContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2952,11 +2166,7 @@ export class ExchangeContract extends BaseContract { newOwner: string, ): string { const self = this as any as ExchangeContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -2967,15 +2177,7 @@ export class ExchangeContract extends BaseContract { ): Promise<void > { const self = this as any as ExchangeContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -2987,11 +2189,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public VERSION = { @@ -3001,12 +2204,7 @@ export class ExchangeContract extends BaseContract { ): Promise<string > { const self = this as any as ExchangeContract; - const functionSignature = 'VERSION()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.VERSION; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('VERSION()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -3017,11 +2215,12 @@ export class ExchangeContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'VERSION'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('VERSION()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -3074,7 +2273,7 @@ export class ExchangeContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('Exchange', 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-wrappers/src/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts index 8a88431b3..530320792 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -27,31 +27,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxDataPayable> = {}, ): Promise<string> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ]); - const encodedData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, makerAssetFillAmount, signatures, feeOrders, @@ -91,23 +67,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, makerAssetFillAmount, signatures, feeOrders, @@ -136,23 +96,7 @@ export class ForwarderContract extends BaseContract { feeRecipient: string, ): string { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, makerAssetFillAmount, signatures, feeOrders, @@ -175,33 +119,7 @@ export class ForwarderContract extends BaseContract { ): Promise<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}] > { const self = this as any as ForwarderContract; - const functionSignature = 'marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketBuyOrdersWithEth; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, makerAssetFillAmount, signatures, feeOrders, @@ -219,11 +137,12 @@ export class ForwarderContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketBuyOrdersWithEth'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256,bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public withdrawAsset = { @@ -233,16 +152,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs; - [assetData, - amount - ] = BaseContract._formatABIDataItemList(inputAbi, [assetData, - amount - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetData, - amount - ]); - const encodedData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData, + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -267,13 +177,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs; - [assetData, - amount - ] = BaseContract._formatABIDataItemList(inputAbi, [assetData, - amount - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData, + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -292,13 +196,7 @@ export class ForwarderContract extends BaseContract { amount: BigNumber, ): string { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs; - [assetData, - amount - ] = BaseContract._formatABIDataItemList(inputAbi, [assetData, - amount - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData, + const abiEncodedTransactionData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount ]); return abiEncodedTransactionData; @@ -311,18 +209,7 @@ export class ForwarderContract extends BaseContract { ): Promise<void > { const self = this as any as ForwarderContract; - const functionSignature = 'withdrawAsset(bytes,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [assetData, - amount - ] = BaseContract._formatABIDataItemList(inputAbi, [assetData, - amount - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [assetData, - amount - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.withdrawAsset; - const encodedData = ethersFunction.encode([assetData, + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -335,11 +222,12 @@ export class ForwarderContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'withdrawAsset'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('withdrawAsset(bytes,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public owner = { @@ -349,12 +237,7 @@ export class ForwarderContract extends BaseContract { ): Promise<string > { const self = this as any as ForwarderContract; - const functionSignature = 'owner()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('owner()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -365,11 +248,12 @@ export class ForwarderContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public marketSellOrdersWithEth = { @@ -383,28 +267,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxDataPayable> = {}, ): Promise<string> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ]); - const encodedData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, signatures, feeOrders, feeSignatures, @@ -441,21 +304,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, signatures, feeOrders, feeSignatures, @@ -482,21 +331,7 @@ export class ForwarderContract extends BaseContract { feeRecipient: string, ): string { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs; - [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders, + const abiEncodedTransactionData = self._strictEncodeArguments('marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, signatures, feeOrders, feeSignatures, @@ -517,30 +352,7 @@ export class ForwarderContract extends BaseContract { ): Promise<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}] > { const self = this as any as ForwarderContract; - const functionSignature = 'marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketSellOrdersWithEth; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)', [orders, signatures, feeOrders, feeSignatures, @@ -557,11 +369,12 @@ export class ForwarderContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'marketSellOrdersWithEth'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],bytes[],uint256,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferOwnership = { @@ -570,13 +383,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -598,11 +405,7 @@ export class ForwarderContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -619,11 +422,7 @@ export class ForwarderContract extends BaseContract { newOwner: string, ): string { const self = this as any as ForwarderContract; - const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); return abiEncodedTransactionData; }, @@ -634,15 +433,7 @@ export class ForwarderContract extends BaseContract { ): Promise<void > { const self = this as any as ForwarderContract; - const functionSignature = 'transferOwnership(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [newOwner - ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership; - const encodedData = ethersFunction.encode([newOwner + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -654,11 +445,12 @@ export class ForwarderContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -725,7 +517,7 @@ _wethAssetData } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('Forwarder', 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-wrappers/src/generated-wrappers/i_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts index 5f38ffdac..6cb9f64fb 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts @@ -25,21 +25,7 @@ export class IValidatorContract extends BaseContract { ): Promise<boolean > { const self = this as any as IValidatorContract; - const functionSignature = 'isValidSignature(bytes32,address,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [hash, - signerAddress, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signerAddress, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [hash, - signerAddress, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isValidSignature; - const encodedData = ethersFunction.encode([hash, + const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash, signerAddress, signature ]); @@ -53,11 +39,12 @@ export class IValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isValidSignature'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -103,7 +90,7 @@ export class IValidatorContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('IValidator', 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-wrappers/src/generated-wrappers/i_wallet.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts index 5fa6f1577..2185c7999 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts @@ -24,18 +24,7 @@ export class IWalletContract extends BaseContract { ): Promise<boolean > { const self = this as any as IWalletContract; - const functionSignature = 'isValidSignature(bytes32,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [hash, - signature - ] = BaseContract._formatABIDataItemList(inputAbi, [hash, - signature - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [hash, - signature - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isValidSignature; - const encodedData = ethersFunction.encode([hash, + const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -48,11 +37,12 @@ export class IWalletContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'isValidSignature'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -98,7 +88,7 @@ export class IWalletContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('IWallet', 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-wrappers/src/generated-wrappers/multi_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts new file mode 100644 index 000000000..418cab6a0 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -0,0 +1,669 @@ +// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name +// tslint:disable:no-unused-variable +// tslint:disable:no-unbound-method +import { BaseContract } from '@0x/base-contract'; +import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types'; +import { BigNumber, classUtils, logUtils } from '@0x/utils'; +import { SimpleContractArtifact } from '@0x/types'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type MultiAssetProxyEventArgs = + | MultiAssetProxyAuthorizedAddressAddedEventArgs + | MultiAssetProxyAuthorizedAddressRemovedEventArgs + | MultiAssetProxyAssetProxyRegisteredEventArgs; + +export enum MultiAssetProxyEvents { + AuthorizedAddressAdded = 'AuthorizedAddressAdded', + AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', + AssetProxyRegistered = 'AssetProxyRegistered', +} + +export interface MultiAssetProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + +export interface MultiAssetProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + +export interface MultiAssetProxyAssetProxyRegisteredEventArgs extends DecodedLogArgs { + id: string; + assetProxy: string; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class MultiAssetProxyContract extends BaseContract { + public assetProxies = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('assetProxies(bytes4)', [index_0 + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('assetProxies(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public addAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.addAuthorizedAddress.estimateGasAsync.bind( + self, + target + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<number> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + target: string, + ): string { + const self = this as any as MultiAssetProxyContract; + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public authorities = { + async callAsync( + index_0: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0 + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public getAssetProxy = { + async callAsync( + assetProxyId: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public removeAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.removeAuthorizedAddress.estimateGasAsync.bind( + self, + target + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<number> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + target: string, + ): string { + const self = this as any as MultiAssetProxyContract; + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public owner = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('owner()', []); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public removeAuthorizedAddressAtIndex = { + async sendTransactionAsync( + target: string, + index: BigNumber, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, + index + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind( + self, + target, + index + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + target: string, + index: BigNumber, + txData: Partial<TxData> = {}, + ): Promise<number> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, + index + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + target: string, + index: BigNumber, + ): string { + const self = this as any as MultiAssetProxyContract; + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, + index + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + index: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target, + index + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public getProxyId = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('getProxyId()', []); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public authorized = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<boolean + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0 + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public registerAssetProxy = { + async sendTransactionAsync( + assetProxy: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.registerAssetProxy.estimateGasAsync.bind( + self, + assetProxy + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + assetProxy: string, + txData: Partial<TxData> = {}, + ): Promise<number> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + assetProxy: string, + ): string { + const self = this as any as MultiAssetProxyContract; + const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy + ]); + return abiEncodedTransactionData; + }, + async callAsync( + assetProxy: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public getAuthorizedAddresses = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string[] + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string[] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferOwnership.estimateGasAsync.bind( + self, + newOwner + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + newOwner: string, + txData: Partial<TxData> = {}, + ): Promise<number> { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + newOwner: string, + ): string { + const self = this as any as MultiAssetProxyContract; + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner + ]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<MultiAssetProxyContract> { + if (_.isUndefined(artifact.compilerOutput)) { + throw new Error('Compiler output not found in the artifact file'); + } + const bytecode = artifact.compilerOutput.evm.bytecode.object; + const abi = artifact.compilerOutput.abi; + return MultiAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<MultiAssetProxyContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, []); + const web3Wrapper = new Web3Wrapper(provider); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + {data: txData}, + txDefaults, + web3Wrapper.estimateGasAsync.bind(web3Wrapper), + ); + const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); + logUtils.log(`transactionHash: ${txHash}`); + const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); + logUtils.log(`MultiAssetProxy successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new MultiAssetProxyContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('MultiAssetProxy', abi, address, provider, txDefaults); + classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count +// tslint:enable:no-unbound-method diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts index ce47b76fc..366b207ad 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts @@ -24,18 +24,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}] > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getOrderAndTraderInfo({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order, - takerAddress - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAddress - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAddress - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrderAndTraderInfo; - const encodedData = ethersFunction.encode([order, + const encodedData = self._strictEncodeArguments('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order, takerAddress ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -48,11 +37,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getOrderAndTraderInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getBalanceAndAllowance = { @@ -64,18 +54,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<[BigNumber, BigNumber] > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getBalanceAndAllowance(address,bytes)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target, - assetData - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - assetData - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - assetData - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getBalanceAndAllowance; - const encodedData = ethersFunction.encode([target, + const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [target, assetData ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -88,11 +67,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getBalanceAndAllowance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getOrdersAndTradersInfo = { @@ -104,18 +84,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>] > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getOrdersAndTradersInfo(tuple[],address[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAddresses - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAddresses - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAddresses - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrdersAndTradersInfo; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders, takerAddresses ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -128,11 +97,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getOrdersAndTradersInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getTradersInfo = { @@ -144,18 +114,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}> > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getTradersInfo(tuple[],address[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [orders, - takerAddresses - ] = BaseContract._formatABIDataItemList(inputAbi, [orders, - takerAddresses - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [orders, - takerAddresses - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTradersInfo; - const encodedData = ethersFunction.encode([orders, + const encodedData = self._strictEncodeArguments('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders, takerAddresses ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -168,11 +127,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getTradersInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}> + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getERC721TokenOwner = { @@ -184,18 +144,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<string > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getERC721TokenOwner(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [token, - tokenId - ] = BaseContract._formatABIDataItemList(inputAbi, [token, - tokenId - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [token, - tokenId - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getERC721TokenOwner; - const encodedData = ethersFunction.encode([token, + const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [token, tokenId ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -208,11 +157,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getERC721TokenOwner'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getBalancesAndAllowances = { @@ -224,18 +174,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<[BigNumber[], BigNumber[]] > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getBalancesAndAllowances(address,bytes[])'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [target, - assetData - ] = BaseContract._formatABIDataItemList(inputAbi, [target, - assetData - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [target, - assetData - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getBalancesAndAllowances; - const encodedData = ethersFunction.encode([target, + const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [target, assetData ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -248,11 +187,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getBalancesAndAllowances'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]] + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public getTraderInfo = { @@ -264,18 +204,7 @@ export class OrderValidatorContract extends BaseContract { ): Promise<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber} > { const self = this as any as OrderValidatorContract; - const functionSignature = 'getTraderInfo({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [order, - takerAddress - ] = BaseContract._formatABIDataItemList(inputAbi, [order, - takerAddress - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [order, - takerAddress - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTraderInfo; - const encodedData = ethersFunction.encode([order, + const encodedData = self._strictEncodeArguments('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order, takerAddress ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -288,11 +217,12 @@ export class OrderValidatorContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'getTraderInfo'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber} + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -352,7 +282,7 @@ _zrxAssetData } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('OrderValidator', 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-wrappers/src/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts index 12ec55ae9..5af169e03 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -57,12 +57,7 @@ export class WETH9Contract extends BaseContract { ): Promise<string > { const self = this as any as WETH9Contract; - const functionSignature = 'name()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('name()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -73,11 +68,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public approve = { @@ -87,16 +83,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [guy, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [guy, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [guy, - wad - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy, wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -121,13 +108,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [guy, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [guy, - wad - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy, wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -146,13 +127,7 @@ export class WETH9Contract extends BaseContract { wad: BigNumber, ): string { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [guy, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [guy, - wad - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [guy, wad ]); return abiEncodedTransactionData; @@ -165,18 +140,7 @@ export class WETH9Contract extends BaseContract { ): Promise<boolean > { const self = this as any as WETH9Contract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [guy, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [guy, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [guy, - wad - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([guy, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy, wad ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -189,11 +153,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public totalSupply = { @@ -203,12 +168,7 @@ export class WETH9Contract extends BaseContract { ): Promise<BigNumber > { const self = this as any as WETH9Contract; - const functionSignature = 'totalSupply()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('totalSupply()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -219,11 +179,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -234,19 +195,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [src, - dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [src, - dst, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [src, - dst, - wad - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [src, dst, wad ]); @@ -274,15 +223,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [src, - dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [src, - dst, - wad - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [src, dst, wad ]); @@ -303,15 +244,7 @@ export class WETH9Contract extends BaseContract { wad: BigNumber, ): string { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [src, - dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [src, - dst, - wad - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [src, dst, wad ]); @@ -326,21 +259,7 @@ export class WETH9Contract extends BaseContract { ): Promise<boolean > { const self = this as any as WETH9Contract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [src, - dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [src, - dst, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [src, - dst, - wad - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([src, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [src, dst, wad ]); @@ -354,11 +273,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public withdraw = { @@ -367,13 +287,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; - [wad - ] = BaseContract._formatABIDataItemList(inputAbi, [wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [wad - ]); - const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -395,11 +309,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; - [wad - ] = BaseContract._formatABIDataItemList(inputAbi, [wad - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -416,11 +326,7 @@ export class WETH9Contract extends BaseContract { wad: BigNumber, ): string { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; - [wad - ] = BaseContract._formatABIDataItemList(inputAbi, [wad - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad + const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad ]); return abiEncodedTransactionData; }, @@ -431,15 +337,7 @@ export class WETH9Contract extends BaseContract { ): Promise<void > { const self = this as any as WETH9Contract; - const functionSignature = 'withdraw(uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [wad - ] = BaseContract._formatABIDataItemList(inputAbi, [wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [wad - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.withdraw; - const encodedData = ethersFunction.encode([wad + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -451,11 +349,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'withdraw'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public decimals = { @@ -465,12 +364,7 @@ export class WETH9Contract extends BaseContract { ): Promise<number > { const self = this as any as WETH9Contract; - const functionSignature = 'decimals()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.decimals; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('decimals()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -481,11 +375,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'decimals'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<number + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -496,15 +391,7 @@ export class WETH9Contract extends BaseContract { ): Promise<BigNumber > { const self = this as any as WETH9Contract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([index_0 + const encodedData = self._strictEncodeArguments('balanceOf(address)', [index_0 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -516,11 +403,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public symbol = { @@ -530,12 +418,7 @@ export class WETH9Contract extends BaseContract { ): Promise<string > { const self = this as any as WETH9Contract; - const functionSignature = 'symbol()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('symbol()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -546,11 +429,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transfer = { @@ -560,16 +444,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [dst, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [dst, - wad - ]); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst, wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -594,13 +469,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [dst, - wad - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst, wad ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -619,13 +488,7 @@ export class WETH9Contract extends BaseContract { wad: BigNumber, ): string { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [dst, - wad - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst, + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [dst, wad ]); return abiEncodedTransactionData; @@ -638,18 +501,7 @@ export class WETH9Contract extends BaseContract { ): Promise<boolean > { const self = this as any as WETH9Contract; - const functionSignature = 'transfer(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [dst, - wad - ] = BaseContract._formatABIDataItemList(inputAbi, [dst, - wad - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [dst, - wad - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer; - const encodedData = ethersFunction.encode([dst, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst, wad ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -662,11 +514,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public deposit = { @@ -674,10 +527,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxDataPayable> = {}, ): Promise<string> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('deposit()').inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const encodedData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]); + const encodedData = self._strictEncodeArguments('deposit()', []); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -696,9 +546,7 @@ export class WETH9Contract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('deposit()').inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]); + const encodedData = self._strictEncodeArguments('deposit()', []); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -713,9 +561,7 @@ export class WETH9Contract extends BaseContract { getABIEncodedTransactionData( ): string { const self = this as any as WETH9Contract; - const inputAbi = self._lookupAbi('deposit()').inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]); + const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []); return abiEncodedTransactionData; }, async callAsync( @@ -724,12 +570,7 @@ export class WETH9Contract extends BaseContract { ): Promise<void > { const self = this as any as WETH9Contract; - const functionSignature = 'deposit()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.deposit; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('deposit()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -740,11 +581,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'deposit'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray; + const abiEncoder = self._lookupAbiEncoder('deposit()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<void + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public allowance = { @@ -756,18 +598,7 @@ export class WETH9Contract extends BaseContract { ): Promise<BigNumber > { const self = this as any as WETH9Contract; - const functionSignature = 'allowance(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [index_0, - index_1 - ] = BaseContract._formatABIDataItemList(inputAbi, [index_0, - index_1 - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, - index_1 - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance; - const encodedData = ethersFunction.encode([index_0, + const encodedData = self._strictEncodeArguments('allowance(address,address)', [index_0, index_1 ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -780,11 +611,12 @@ export class WETH9Contract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -830,7 +662,7 @@ export class WETH9Contract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('WETH9', 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-wrappers/src/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts index 877ffd12d..4f5d7f4c5 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -43,12 +43,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<string > { const self = this as any as ZRXTokenContract; - const functionSignature = 'name()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('name()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -59,11 +54,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public approve = { @@ -73,16 +69,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -107,13 +94,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -132,13 +113,7 @@ export class ZRXTokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender, + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); return abiEncodedTransactionData; @@ -151,18 +126,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ZRXTokenContract; - const functionSignature = 'approve(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_spender, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_spender, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve; - const encodedData = ethersFunction.encode([_spender, + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -175,11 +139,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public totalSupply = { @@ -189,12 +154,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ZRXTokenContract; - const functionSignature = 'totalSupply()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('totalSupply()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -205,11 +165,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transferFrom = { @@ -220,19 +181,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -260,15 +209,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -289,15 +230,7 @@ export class ZRXTokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from, + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -312,21 +245,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ZRXTokenContract; - const functionSignature = 'transferFrom(address,address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_from, - _to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_from, - _to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_from, - _to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom; - const encodedData = ethersFunction.encode([_from, + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from, _to, _value ]); @@ -340,11 +259,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public decimals = { @@ -354,12 +274,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<number > { const self = this as any as ZRXTokenContract; - const functionSignature = 'decimals()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.decimals; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('decimals()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -370,11 +285,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'decimals'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<number + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public balanceOf = { @@ -385,15 +301,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ZRXTokenContract; - const functionSignature = 'balanceOf(address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf; - const encodedData = ethersFunction.encode([_owner + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -405,11 +313,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public symbol = { @@ -419,12 +328,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<string > { const self = this as any as ZRXTokenContract; - const functionSignature = 'symbol()'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, []); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol; - const encodedData = ethersFunction.encode([]); + const encodedData = self._strictEncodeArguments('symbol()', []); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -435,11 +339,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<string + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public transfer = { @@ -449,16 +354,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<string> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -483,13 +379,7 @@ export class ZRXTokenContract extends BaseContract { txData: Partial<TxData> = {}, ): Promise<number> { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -508,13 +398,7 @@ export class ZRXTokenContract extends BaseContract { _value: BigNumber, ): string { const self = this as any as ZRXTokenContract; - const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to, + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); return abiEncodedTransactionData; @@ -527,18 +411,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<boolean > { const self = this as any as ZRXTokenContract; - const functionSignature = 'transfer(address,uint256)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_to, - _value - ] = BaseContract._formatABIDataItemList(inputAbi, [_to, - _value - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_to, - _value - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer; - const encodedData = ethersFunction.encode([_to, + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -551,11 +424,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<boolean + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public allowance = { @@ -567,18 +441,7 @@ export class ZRXTokenContract extends BaseContract { ): Promise<BigNumber > { const self = this as any as ZRXTokenContract; - const functionSignature = 'allowance(address,address)'; - const inputAbi = self._lookupAbi(functionSignature).inputs; - [_owner, - _spender - ] = BaseContract._formatABIDataItemList(inputAbi, [_owner, - _spender - ], BaseContract._bigNumberToString.bind(self)); - BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner, - _spender - ]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance; - const encodedData = ethersFunction.encode([_owner, + const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner, _spender ]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( @@ -591,11 +454,12 @@ export class ZRXTokenContract extends BaseContract { ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); - let resultArray = ethersFunction.decode(rawCallResult); - const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs; - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); - resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); - return resultArray[0]; + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<BigNumber + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, }; public static async deployFrom0xArtifactAsync( @@ -641,7 +505,7 @@ export class ZRXTokenContract extends BaseContract { } constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { super('ZRXToken', 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-wrappers/src/index.ts b/packages/abi-gen-wrappers/src/index.ts index b5a7d0cfe..1a81c0187 100644 --- a/packages/abi-gen-wrappers/src/index.ts +++ b/packages/abi-gen-wrappers/src/index.ts @@ -10,6 +10,7 @@ export * from './generated-wrappers/exchange'; export * from './generated-wrappers/forwarder'; export * from './generated-wrappers/i_validator'; export * from './generated-wrappers/i_wallet'; +export * from './generated-wrappers/multi_asset_proxy'; export * from './generated-wrappers/order_validator'; export * from './generated-wrappers/weth9'; export * from './generated-wrappers/zrx_token'; diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 4bbcdc897..ab516e4c6 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.22", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.21", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.20", "changes": [ diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 26d42cd36..af74218b8 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.22 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.21 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.20 - _January 9, 2019_ * Dependencies updated diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 4a2754233..7f968893c 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0x/abi-gen", - "version": "1.0.20", + "version": "1.0.22", "engines": { "node": ">=6.12" }, @@ -31,10 +31,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", "chalk": "^2.3.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "glob": "^7.1.2", "handlebars": "^4.0.11", "lodash": "^4.17.5", @@ -45,7 +45,7 @@ "yargs": "^10.0.3" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/glob": "5.0.35", "@types/handlebars": "^4.0.36", "@types/mkdirp": "^0.5.1", diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 5bad920ca..6e0ca2c87 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { abiUtils, logUtils } from '@0x/utils'; +import { AbiEncoder, abiUtils, logUtils } from '@0x/utils'; import chalk from 'chalk'; import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from 'ethereum-types'; import { sync as globSync } from 'glob'; @@ -133,7 +133,7 @@ for (const abiFileName of abiFileNames) { singleReturnValue: methodAbi.outputs.length === 1, hasReturnValue: methodAbi.outputs.length !== 0, tsName: sanitizedMethodAbis[methodAbiIndex].name, - functionSignature: abiUtils.getFunctionSignature(methodAbi), + functionSignature: new AbiEncoder.Method(methodAbi).getSignature(), }; return methodData; }); diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 0e89b408e..0210f9400 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.23", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.22", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.21", "changes": [ diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index 25383b2d1..5a4af165a 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.23 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.22 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.21 - _January 9, 2019_ * Dependencies updated diff --git a/packages/assert/package.json b/packages/assert/package.json index e11ccb3cb..38481d6f0 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0x/assert", - "version": "1.0.21", + "version": "1.0.23", "engines": { "node": ">=6.12" }, @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/valid-url": "^1.0.2", @@ -44,9 +44,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/json-schemas": "^2.1.5", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", + "@0x/json-schemas": "^2.1.7", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", "lodash": "^4.17.5", "valid-url": "^1.0.9" }, diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index 484ad1625..909236772 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -8,13 +8,23 @@ ] }, { + "timestamp": 1547561734, + "version": "4.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.0.0", "changes": [ { "note": "Raise custom InsufficientAssetLiquidityError error with amountAvailableToFill attribute", "pr": 1437 } - ] + ], + "timestamp": 1547225310 }, { "timestamp": 1547040760, diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index 70bbe8302..85c02479a 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.1 - _January 15, 2019_ + + * Dependencies updated + +## v4.0.0 - _January 11, 2019_ + + * Raise custom InsufficientAssetLiquidityError error with amountAvailableToFill attribute (#1437) + ## v3.0.5 - _January 9, 2019_ * Dependencies updated diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 1aa178b9f..45cd8954d 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,6 +1,6 @@ { "name": "@0x/asset-buyer", - "version": "3.0.5", + "version": "4.0.1", "engines": { "node": ">=6.12" }, @@ -36,21 +36,21 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/connect": "^3.0.11", - "@0x/contract-wrappers": "^4.2.0", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", - "ethereum-types": "^1.1.4", + "@0x/assert": "^1.0.23", + "@0x/connect": "^3.0.13", + "@0x/contract-wrappers": "^5.0.0", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", + "ethereum-types": "^1.1.6", "lodash": "^4.17.5" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "^4.14.116", "@types/mocha": "^2.2.42", "@types/node": "*", diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index 25e85b2cc..4244d196c 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -105,7 +105,7 @@ function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( // get corresponding on-chain state for the order const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating - if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { + if (orderInfo.orderStatus !== OrderStatus.Fillable) { return accOrders; } // if the order IS fillable, add the order and calculate the remaining fillable amount diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index bd54400d3..68ebe8d9e 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "3.0.11", "changes": [ diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index 7a1a96639..975a56fd4 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.13 - _January 15, 2019_ + + * Dependencies updated + +## v3.0.12 - _January 11, 2019_ + + * Dependencies updated + ## v3.0.11 - _January 9, 2019_ * Dependencies updated diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 7193c4881..db09b16a1 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0x/base-contract", - "version": "3.0.11", + "version": "3.0.13", "engines": { "node": ">=6.12" }, @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "chai": "^4.0.1", "make-promises-safe": "^1.1.0", @@ -40,10 +40,10 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", - "ethereum-types": "^1.1.4", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5" }, diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index fbb8478b7..c2b7b943b 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -1,4 +1,4 @@ -import { abiUtils, BigNumber } from '@0x/utils'; +import { AbiEncoder, abiUtils } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { AbiDefinition, @@ -16,8 +16,8 @@ import * as _ from 'lodash'; import { formatABIDataItem } from './utils'; -export interface EthersInterfaceByFunctionSignature { - [key: string]: ethers.utils.Interface; +export interface AbiEncoderByFunctionSignature { + [key: string]: AbiEncoder.Method; } const REVERT_ERROR_SELECTOR = '08c379a0'; @@ -26,7 +26,7 @@ const REVERT_ERROR_SELECTOR_BYTES_LENGTH = 4; const REVERT_ERROR_SELECTOR_END = REVERT_ERROR_SELECTOR_OFFSET + REVERT_ERROR_SELECTOR_BYTES_LENGTH * 2; export class BaseContract { - protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature; + protected _abiEncoderByFunctionSignature: AbiEncoderByFunctionSignature; protected _web3Wrapper: Web3Wrapper; public abi: ContractAbi; public address: string; @@ -65,9 +65,6 @@ export class BaseContract { return defaultConstructorAbi; } } - protected static _bnToBigNumber(_type: string, value: any): any { - return _.isObject(value) && value._hex ? new BigNumber(value.toString()) : value; - } protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>( txData: T, txDefaults: Partial<TxData>, @@ -89,10 +86,15 @@ export class BaseContract { } protected static _throwIfRevertWithReasonCallResult(rawCallResult: string): void { if (rawCallResult.slice(REVERT_ERROR_SELECTOR_OFFSET, REVERT_ERROR_SELECTOR_END) === REVERT_ERROR_SELECTOR) { - const revertReason = ethers.utils.defaultAbiCoder.decode( - ['string'], + const revertReasonArray = AbiEncoder.create('(string)').decodeAsArray( ethers.utils.hexDataSlice(rawCallResult, REVERT_ERROR_SELECTOR_BYTES_LENGTH), ); + if (revertReasonArray.length !== 1) { + throw new Error( + `Cannot safely decode revert reason: Expected an array with one element, got ${revertReasonArray}`, + ); + } + const revertReason = revertReasonArray[0]; throw new Error(revertReason); } } @@ -100,11 +102,11 @@ export class BaseContract { // the given inputAbi. An argument may not be considered safely encodeable // if it overflows the corresponding Solidity type, there is a bug in the // encoder, or the encoder performs unsafe type coercion. - public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): void { - const coder = new ethers.utils.AbiCoder(); + public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): string { + const abiEncoder = AbiEncoder.create(inputAbi); const params = abiUtils.parseEthersParams(inputAbi); - const rawEncoded = coder.encode(inputAbi, args); - const rawDecoded = coder.decode(inputAbi, rawEncoded); + const rawEncoded = abiEncoder.encode(args); + const rawDecoded = abiEncoder.decodeAsArray(rawEncoded); for (let i = 0; i < rawDecoded.length; i++) { const original = args[i]; const decoded = rawDecoded[i]; @@ -116,13 +118,14 @@ export class BaseContract { ); } } + return rawEncoded; } - protected _lookupEthersInterface(functionSignature: string): ethers.utils.Interface { - const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature]; - if (_.isUndefined(ethersInterface)) { + protected _lookupAbiEncoder(functionSignature: string): AbiEncoder.Method { + const abiEncoder = this._abiEncoderByFunctionSignature[functionSignature]; + if (_.isUndefined(abiEncoder)) { throw new Error(`Failed to lookup method with function signature '${functionSignature}'`); } - return ethersInterface; + return abiEncoder; } protected _lookupAbi(functionSignature: string): MethodAbi { const methodAbi = _.find(this.abi, (abiDefinition: AbiDefinition) => { @@ -130,7 +133,7 @@ export class BaseContract { return false; } // tslint:disable-next-line:no-unnecessary-type-assertion - const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition as MethodAbi); + const abiFunctionSignature = new AbiEncoder.Method(abiDefinition as MethodAbi).getSignature(); if (abiFunctionSignature === functionSignature) { return true; } @@ -138,6 +141,15 @@ export class BaseContract { }) as MethodAbi; return methodAbi; } + protected _strictEncodeArguments(functionSignature: string, functionArguments: any): string { + const abiEncoder = this._lookupAbiEncoder(functionSignature); + const inputAbi = abiEncoder.getDataItem().components; + if (inputAbi === undefined) { + throw new Error(`Undefined Method Input ABI`); + } + const abiEncodedArguments = abiEncoder.encode(functionArguments); + return abiEncodedArguments; + } constructor( contractName: string, abi: ContractAbi, @@ -152,10 +164,11 @@ export class BaseContract { const methodAbis = this.abi.filter( (abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Function, ) as MethodAbi[]; - this._ethersInterfacesByFunctionSignature = {}; + this._abiEncoderByFunctionSignature = {}; _.each(methodAbis, methodAbi => { - const functionSignature = abiUtils.getFunctionSignature(methodAbi); - this._ethersInterfacesByFunctionSignature[functionSignature] = new ethers.utils.Interface([methodAbi]); + const abiEncoder = new AbiEncoder.Method(methodAbi); + const functionSignature = abiEncoder.getSignature(); + this._abiEncoderByFunctionSignature[functionSignature] = abiEncoder; }); } } diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index 2f323f891..8fe9c562f 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "3.0.11", "changes": [ diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index d01caa613..7556aae72 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.13 - _January 15, 2019_ + + * Dependencies updated + +## v3.0.12 - _January 11, 2019_ + + * Dependencies updated + ## v3.0.11 - _January 9, 2019_ * Dependencies updated diff --git a/packages/connect/package.json b/packages/connect/package.json index 76817f23e..15a4c12f1 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0x/connect", - "version": "3.0.11", + "version": "3.0.13", "engines": { "node": ">=6.12" }, @@ -44,12 +44,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", + "@0x/assert": "^1.0.23", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", "lodash": "^4.17.5", "query-string": "^5.0.1", "sinon": "^4.0.0", @@ -57,7 +57,7 @@ "websocket": "^1.0.25" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/fetch-mock": "^6.0.3", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", diff --git a/packages/contract-addresses/CHANGELOG.json b/packages/contract-addresses/CHANGELOG.json index 36684d443..8800f2f73 100644 --- a/packages/contract-addresses/CHANGELOG.json +++ b/packages/contract-addresses/CHANGELOG.json @@ -1,5 +1,15 @@ [ { + "version": "2.2.0", + "changes": [ + { + "note": "Added migration for `MultiAssetProxy` contract", + "pr": 1503 + } + ], + "timestamp": 1547561734 + }, + { "version": "2.1.0", "changes": [ { diff --git a/packages/contract-addresses/CHANGELOG.md b/packages/contract-addresses/CHANGELOG.md index d7f2ff7ea..1f3d187a4 100644 --- a/packages/contract-addresses/CHANGELOG.md +++ b/packages/contract-addresses/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.2.0 - _January 15, 2019_ + + * Added migration for `MultiAssetProxy` contract (#1503) + ## v2.1.0 - _January 9, 2019_ * Added testnet entries for Dutch Auction contract (kovan,rinkeby,ropsten) (#1465) diff --git a/packages/contract-addresses/package.json b/packages/contract-addresses/package.json index c5a133ddf..260322081 100644 --- a/packages/contract-addresses/package.json +++ b/packages/contract-addresses/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contract-addresses", - "version": "2.1.0", + "version": "2.2.0", "engines": { "node": ">=6.12" }, diff --git a/packages/contract-addresses/src/index.ts b/packages/contract-addresses/src/index.ts index d181a1bec..4f580e825 100644 --- a/packages/contract-addresses/src/index.ts +++ b/packages/contract-addresses/src/index.ts @@ -70,15 +70,15 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { }, // NetworkId 50 represents our Ganache snapshot generated from migrations. 50: { - exchange: '0x48bacb9266a570d521063ef5dd96e61686dbe788', erc20Proxy: '0x1dc4c1cefef38a777b15aa20260a54e584b16c48', erc721Proxy: '0x1d7022f5b17d2f8b695918fb48fa1089c9f85401', zrxToken: '0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c', etherToken: '0x0b1ba0af832d7c05fd64161e0db78e85978e8082', - assetProxyOwner: '0x34d402f14d58e001d8efbe6585051bf9706aa064', - forwarder: '0xb69e673309512a9d726f87304c6984054f87a93b', - orderValidator: '0xe86bb98fcf9bff3512c74589b78fb168200cc546', - dutchAuction: '0xdc688d29394a3f1e6f1e5100862776691afaf3d2', + exchange: '0x48bacb9266a570d521063ef5dd96e61686dbe788', + assetProxyOwner: '0x04b5dadd2c0d6a261bfafbc964e0cac48585def3', + forwarder: '0x6000eca38b8b5bba64986182fe2a69c57f6b5414', + orderValidator: '0x32eecaf51dfea9618e9bc94e9fbfddb1bbdcba15', + dutchAuction: '0x7e3f4e1deb8d3a05d9d2da87d9521268d0ec3239', }, }; diff --git a/packages/contract-artifacts/CHANGELOG.json b/packages/contract-artifacts/CHANGELOG.json index 237014d09..c488fa5c5 100644 --- a/packages/contract-artifacts/CHANGELOG.json +++ b/packages/contract-artifacts/CHANGELOG.json @@ -1,5 +1,15 @@ [ { + "version": "1.3.0", + "changes": [ + { + "note": "Added artifact for `MultiAssetProxy` contract", + "pr": 1503 + } + ], + "timestamp": 1547561734 + }, + { "version": "1.2.0", "changes": [ { diff --git a/packages/contract-artifacts/CHANGELOG.md b/packages/contract-artifacts/CHANGELOG.md index 7f96cb571..c1118a3b9 100644 --- a/packages/contract-artifacts/CHANGELOG.md +++ b/packages/contract-artifacts/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.3.0 - _January 15, 2019_ + + * Added artifact for `MultiAssetProxy` contract (#1503) + ## v1.2.0 - _January 9, 2019_ * Added artifact for Dutch Auction contract (#1465) diff --git a/packages/contract-artifacts/artifacts/MultiAssetProxy.json b/packages/contract-artifacts/artifacts/MultiAssetProxy.json new file mode 100644 index 000000000..f143cd817 --- /dev/null +++ b/packages/contract-artifacts/artifacts/MultiAssetProxy.json @@ -0,0 +1,263 @@ +{ + "schemaVersion": "2.0.0", + "contractName": "MultiAssetProxy", + "compilerOutput": { + "abi": [ + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "bytes4" + } + ], + "name": "assetProxies", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "target", + "type": "address" + } + ], + "name": "addAuthorizedAddress", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "uint256" + } + ], + "name": "authorities", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "assetProxyId", + "type": "bytes4" + } + ], + "name": "getAssetProxy", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "target", + "type": "address" + } + ], + "name": "removeAuthorizedAddress", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "target", + "type": "address" + }, + { + "name": "index", + "type": "uint256" + } + ], + "name": "removeAuthorizedAddressAtIndex", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getProxyId", + "outputs": [ + { + "name": "", + "type": "bytes4" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "authorized", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "assetProxy", + "type": "address" + } + ], + "name": "registerAssetProxy", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAuthorizedAddresses", + "outputs": [ + { + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "payable": false, + "stateMutability": "nonpayable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "target", + "type": "address" + }, + { + "indexed": true, + "name": "caller", + "type": "address" + } + ], + "name": "AuthorizedAddressAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "target", + "type": "address" + }, + { + "indexed": true, + "name": "caller", + "type": "address" + } + ], + "name": "AuthorizedAddressRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "id", + "type": "bytes4" + }, + { + "indexed": false, + "name": "assetProxy", + "type": "address" + } + ], + "name": "AssetProxyRegistered", + "type": "event" + } + ], + "evm": { + "bytecode": { + "linkReferences": {}, + "object": "0x608060405260008054600160a060020a03191633179055611527806100256000396000f3006080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633fd3c997811461048457806342f1181e146104e7578063494503d414610517578063607041081461052f57806370712939146105695780638da5cb5b146105975780639ad26744146105ac578063ae25532e146105dd578063b918161114610627578063c585bb9314610669578063d39de6e914610697578063f2fde38b146106fc575b3480156100c557600080fd5b507fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e40000000000000000000000000000000000000000000000000000000081141561047f573360005260026020526040600020541515610199577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b600435602881013560488201356048820183016020810335604883018501602081033580830315610235577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f4c454e4754485f4d49534d4154434800000000000000000000000000604052600060605260646000fd5b60646000803760806004526064356020840260008060005b8381101561047c5780890135858102818782041487151715156102db577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1055494e543235365f4f564552464c4f57000000000000000000000000604052600060605260646000fd5b8060645282890135606881018d018f01602081038035600481101561038a577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1e4c454e4754485f475245415445525f5448414e5f335f5245515549526040527f454400000000000000000000000000000000000000000000000000000000000060605260646000fd5b7fffffffff00000000000000000000000000000000000000000000000000000000833516898103156103cb5780995089608452600160a45260406084205498505b881515610443577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1a41535345545f50524f58595f444f45535f4e4f545f45584953540000604052600060605260646000fd5b60208201836084376000808360a4016000808d5af1801515610469573d6000803e3d6000fd5b505050505050505060208101905061024d565b50005b600080fd5b34801561049057600080fd5b506104be7fffffffff000000000000000000000000000000000000000000000000000000006004351661072a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156104f357600080fd5b5061051573ffffffffffffffffffffffffffffffffffffffff60043516610752565b005b34801561052357600080fd5b506104be60043561093e565b34801561053b57600080fd5b506104be7fffffffff0000000000000000000000000000000000000000000000000000000060043516610973565b34801561057557600080fd5b5061051573ffffffffffffffffffffffffffffffffffffffff600435166109bd565b3480156105a357600080fd5b506104be610cb6565b3480156105b857600080fd5b5061051573ffffffffffffffffffffffffffffffffffffffff60043516602435610cd2565b3480156105e957600080fd5b506105f2611087565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b34801561063357600080fd5b5061065573ffffffffffffffffffffffffffffffffffffffff600435166110bd565b604080519115158252519081900360200190f35b34801561067557600080fd5b5061051573ffffffffffffffffffffffffffffffffffffffff600435166110d2565b3480156106a357600080fd5b506106ac61135f565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156106e85781810151838201526020016106d0565b505050509050019250505060405180910390f35b34801561070857600080fd5b5061051573ffffffffffffffffffffffffffffffffffffffff600435166113ce565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146107d857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205460ff161561086d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915560038054918201815583527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b600380548290811061094c57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081526001602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000805473ffffffffffffffffffffffffffffffffffffffff163314610a4457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604090205460ff161515610ada57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b5073ffffffffffffffffffffffffffffffffffffffff8116600090815260026020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600354811015610c6f578173ffffffffffffffffffffffffffffffffffffffff16600382815481101515610b5757fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff161415610c6757600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610baf57fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610be257fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610c6190826114b4565b50610c6f565b600101610b27565b604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d5857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604090205460ff161515610dee57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6003548110610e5e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff16600382815481101515610e8457fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610f1257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610f8d57fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610fc057fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061103f90826114b4565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f4d756c746941737365742875696e743235365b5d2c62797465735b5d290000008152905190819003601d0190205b90565b60026020526000908152604090205460ff1681565b600080548190819073ffffffffffffffffffffffffffffffffffffffff16331461115d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b8392508273ffffffffffffffffffffffffffffffffffffffff1663ae25532e6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156111c457600080fd5b505af11580156111d8573d6000803e3d6000fd5b505050506040513d60208110156111ee57600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000811660009081526001602052604090205490925073ffffffffffffffffffffffffffffffffffffffff16905080156112aa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f41535345545f50524f58595f414c52454144595f455849535453000000000000604482015290519081900360640190fd5b7fffffffff00000000000000000000000000000000000000000000000000000000821660008181526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88811691909117909155825193845287169083015280517fd2c6b762299c609bdb96520b58a49bfb80186934d4f71a86a367571a15c031949281900390910190a150505050565b606060038054806020026020016040519081016040528092919081815260200182805480156113c457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611399575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331461145457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116156114b157600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b8154818355818111156114d8576000838152602090206114d89181019083016114dd565b505050565b6110ba91905b808211156114f757600081556001016114e3565b50905600a165627a7a72305820edc27b59aaf514c0deebc8a00d0f17f092fc6e8b8544bcccb6f7e8f4a81c781d0029" + } + } + }, + "networks": {} +} diff --git a/packages/contract-artifacts/package.json b/packages/contract-artifacts/package.json index b819520c6..6a98615d7 100644 --- a/packages/contract-artifacts/package.json +++ b/packages/contract-artifacts/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contract-artifacts", - "version": "1.2.0", + "version": "1.3.0", "engines": { "node": ">=6.12" }, diff --git a/packages/contract-artifacts/src/index.ts b/packages/contract-artifacts/src/index.ts index bd5f8fee3..1cbda9518 100644 --- a/packages/contract-artifacts/src/index.ts +++ b/packages/contract-artifacts/src/index.ts @@ -1,7 +1,7 @@ import * as AssetProxyOwner from '../artifacts/AssetProxyOwner.json'; -import * as DutchAuction from '../artifacts/DutchAuction.json'; import * as DummyERC20Token from '../artifacts/DummyERC20Token.json'; import * as DummyERC721Token from '../artifacts/DummyERC721Token.json'; +import * as DutchAuction from '../artifacts/DutchAuction.json'; import * as ERC20Proxy from '../artifacts/ERC20Proxy.json'; import * as ERC20Token from '../artifacts/ERC20Token.json'; import * as ERC721Proxy from '../artifacts/ERC721Proxy.json'; @@ -10,6 +10,7 @@ import * as Exchange from '../artifacts/Exchange.json'; import * as Forwarder from '../artifacts/Forwarder.json'; import * as IValidator from '../artifacts/IValidator.json'; import * as IWallet from '../artifacts/IWallet.json'; +import * as MultiAssetProxy from '../artifacts/MultiAssetProxy.json'; import * as OrderValidator from '../artifacts/OrderValidator.json'; import * as WETH9 from '../artifacts/WETH9.json'; import * as ZRXToken from '../artifacts/ZRXToken.json'; @@ -27,6 +28,7 @@ export { Forwarder, IValidator, IWallet, + MultiAssetProxy, OrderValidator, WETH9, ZRXToken, diff --git a/packages/contract-artifacts/tsconfig.json b/packages/contract-artifacts/tsconfig.json index 59169fceb..1aef41bb8 100644 --- a/packages/contract-artifacts/tsconfig.json +++ b/packages/contract-artifacts/tsconfig.json @@ -19,6 +19,7 @@ "./artifacts/Forwarder.json", "./artifacts/IValidator.json", "./artifacts/IWallet.json", + "./artifacts/MultiAssetProxy.json", "./artifacts/OrderValidator.json", "./artifacts/WETH9.json", "./artifacts/ZRXToken.json" diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 2ba6c9f10..bfba8454c 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,5 +1,28 @@ [ { + "version": "5.0.0", + "changes": [ + { + "note": "Renamed OrderStatus enum members to PascalCase to conform with tslint enum-naming rule", + "pr": 1474 + }, + { + "note": "Remove Exchange `matchOrdersAsync` optimization", + "pr": 1514 + } + ], + "timestamp": 1547561734 + }, + { + "timestamp": 1547225310, + "version": "4.2.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.2.0", "changes": [ { diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index fe7bb7b81..8281f5050 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v5.0.0 - _January 15, 2019_ + + * Renamed OrderStatus enum members to PascalCase to conform with tslint enum-naming rule (#1474) + * Remove Exchange `matchOrdersAsync` optimization (#1514) + +## v4.2.1 - _January 11, 2019_ + + * Dependencies updated + ## v4.2.0 - _January 9, 2019_ * Added Dutch Auction wrapper (#1465) diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 708b4249a..c4f75a5a4 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contract-wrappers", - "version": "4.2.0", + "version": "5.0.0", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -37,10 +37,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/migrations": "^2.3.0", - "@0x/subproviders": "^2.1.9", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/migrations": "^2.4.0", + "@0x/subproviders": "^2.1.11", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/node": "*", @@ -65,19 +65,19 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/assert": "^1.0.21", - "@0x/contract-addresses": "^2.1.0", - "@0x/contract-artifacts": "^1.2.0", - "@0x/contracts-test-utils": "^1.0.3", - "@0x/fill-scenarios": "^1.1.0", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", - "ethereum-types": "^1.1.4", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/assert": "^1.0.23", + "@0x/contract-addresses": "^2.2.0", + "@0x/contract-artifacts": "^1.3.0", + "@0x/contracts-test-utils": "^2.0.0", + "@0x/fill-scenarios": "^1.1.2", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", + "ethereum-types": "^1.1.6", "ethereumjs-abi": "0.6.5", "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index c9556971a..49193f816 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -743,10 +743,6 @@ export class ExchangeWrapper extends ContractWrapper { rightSignedOrder.takerAssetData !== leftSignedOrder.makerAssetData ) { throw new Error(ExchangeWrapperError.AssetDataMismatch); - } else { - // Smart contracts assigns the asset data from the left order to the right one so we can save gas on reducing the size of call data - rightSignedOrder.makerAssetData = '0x'; - rightSignedOrder.takerAssetData = '0x'; } const exchangeInstance = await this._getExchangeContractAsync(); if (orderTransactionOpts.shouldValidate) { diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts index 945ca88cd..29cf8b2c4 100644 --- a/packages/contract-wrappers/src/types.ts +++ b/packages/contract-wrappers/src/types.ts @@ -177,13 +177,13 @@ export interface OrderInfo { } export enum OrderStatus { - INVALID = 0, - INVALID_MAKER_ASSET_AMOUNT, - INVALID_TAKER_ASSET_AMOUNT, - FILLABLE, - EXPIRED, - FULLY_FILLED, - CANCELLED, + Invalid = 0, + InvalidMakerAssetAmount, + InvalidTakerAssetAmount, + Fillable, + Expired, + FullyFilled, + Cancelled, } export interface TraderInfo { diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index 73ce6c743..a1d60dc6e 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -109,7 +109,7 @@ describe('ExchangeWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder); - expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled); }); }); describe('#fillOrKillOrderAsync', () => { @@ -157,7 +157,7 @@ describe('ExchangeWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder); - expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled); }); }); describe('#marketSellOrdersAsync', () => { @@ -183,7 +183,7 @@ describe('ExchangeWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder); - expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled); }); }); describe('#batchFillOrdersNoThrowAsync', () => { @@ -197,9 +197,9 @@ describe('ExchangeWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); let orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder); - expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled); orderInfo = await contractWrappers.exchange.getOrderInfoAsync(anotherSignedOrder); - expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled); }); }); describe('#batchFillOrKillOrdersAsync', () => { diff --git a/packages/contract-wrappers/test/forwarder_wrapper_test.ts b/packages/contract-wrappers/test/forwarder_wrapper_test.ts index ff4ff8b67..0d197eced 100644 --- a/packages/contract-wrappers/test/forwarder_wrapper_test.ts +++ b/packages/contract-wrappers/test/forwarder_wrapper_test.ts @@ -97,8 +97,8 @@ describe('ForwarderWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const ordersInfo = await contractWrappers.exchange.getOrdersInfoAsync([signedOrder, anotherSignedOrder]); - expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); - expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); + expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FullyFilled); + expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FullyFilled); }); it('should throw when invalid transaction and shouldValidate is true', async () => { const signedOrders = [signedOrder]; @@ -131,8 +131,8 @@ describe('ForwarderWrapper', () => { ); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const ordersInfo = await contractWrappers.exchange.getOrdersInfoAsync([signedOrder, anotherSignedOrder]); - expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED); - expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FILLABLE); + expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FullyFilled); + expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.Fillable); expect(ordersInfo[1].orderTakerAssetFilledAmount).to.be.bignumber.equal(new BigNumber(4)); // only 95% of ETH is sold }); it('should throw when invalid transaction and shouldValidate is true', async () => { diff --git a/packages/contract-wrappers/test/order_validator_wrapper_test.ts b/packages/contract-wrappers/test/order_validator_wrapper_test.ts index da3f99e72..c61c05d31 100644 --- a/packages/contract-wrappers/test/order_validator_wrapper_test.ts +++ b/packages/contract-wrappers/test/order_validator_wrapper_test.ts @@ -117,9 +117,9 @@ describe('OrderValidator', () => { it('should return correct on-chain order info for input orders', async () => { const firstOrderInfo = ordersInfo[0]; const secondOrderInfo = ordersInfo[1]; - expect(firstOrderInfo.orderStatus).to.be.equal(OrderStatus.FILLABLE); + expect(firstOrderInfo.orderStatus).to.be.equal(OrderStatus.Fillable); expect(firstOrderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); - expect(secondOrderInfo.orderStatus).to.be.equal(OrderStatus.FILLABLE); + expect(secondOrderInfo.orderStatus).to.be.equal(OrderStatus.Fillable); expect(secondOrderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return correct on-chain trader info for input takers', async () => { diff --git a/packages/contract-wrappers/test/utils/token_utils.ts b/packages/contract-wrappers/test/utils/token_utils.ts index f8a88637f..e390d2775 100644 --- a/packages/contract-wrappers/test/utils/token_utils.ts +++ b/packages/contract-wrappers/test/utils/token_utils.ts @@ -9,14 +9,14 @@ import { provider, txDefaults, web3Wrapper } from './web3_wrapper'; // Before we were fetching them from the TokenRegistry but now we can't as it's deprecated and removed. // TODO(albrow): Import these from the migrations package instead of hard-coding them. const DUMMY_ERC_20_ADRESSES = [ - '0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f', - '0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db', - '0xf22469f31527adc53284441bae1665a7b9214dba', - '0x10add991de718a69dec2117cb6aa28098836511b', - '0x8d61158a366019ac78db4149d75fff9dda51160d', + '0x34d402f14d58e001d8efbe6585051bf9706aa064', + '0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3', + '0xcdb594a32b1cc3479d8746279712c39d18a07fc0', + '0x1e2f9e10d02a6b8f8f69fcbf515e75039d2ea30d', + '0xbe0037eaf2d64fe5529bca93c18c9702d3930376', ]; -const DUMMY_ERC_721_ADRESSES = ['0x131855dda0aaff096f6854854c55a4debf61077a']; +const DUMMY_ERC_721_ADRESSES = ['0x07f96aa816c1f244cbc6ef114bb2b023ba54a2eb']; export const tokenUtils = { getDummyERC20TokenAddresses(): string[] { diff --git a/packages/dev-tools-pages/package.json b/packages/dev-tools-pages/package.json index db927849e..79d4a840f 100644 --- a/packages/dev-tools-pages/package.json +++ b/packages/dev-tools-pages/package.json @@ -1,6 +1,6 @@ { "name": "@0x/dev-tools-pages", - "version": "0.0.11", + "version": "0.0.13", "engines": { "node": ">=6.12" }, @@ -16,7 +16,7 @@ }, "license": "Apache-2.0", "dependencies": { - "@0x/react-shared": "^1.1.0", + "@0x/react-shared": "^1.1.2", "basscss": "^8.0.3", "bowser": "^1.9.3", "highlight.js": "^9.13.1", @@ -71,6 +71,6 @@ "puppeteerArgs": [ "--no-sandbox", "--disable-setuid-sandbox" - ] + ] } } diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index 8f355466c..85189d70b 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.24", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.23", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.22", "changes": [ diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index 04ee860b5..958fded86 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.24 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.23 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.22 - _January 9, 2019_ * Dependencies updated diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index cb27ad5c5..4ab1d6439 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/dev-utils", - "version": "1.0.22", + "version": "1.0.24", "engines": { "node": ">=6.12" }, @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "make-promises-safe": "^1.1.0", @@ -41,14 +41,14 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/web3-provider-engine": "^14.0.0", "chai": "^4.0.1", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/devnet/genesis.json b/packages/devnet/genesis.json index 073672dd9..03dc5d623 100644 --- a/packages/devnet/genesis.json +++ b/packages/devnet/genesis.json @@ -8,7 +8,7 @@ "eip158Block": 3, "byzantiumBlock": 4, "clique": { - "period": 0, + "period": 1, "epoch": 30000 } }, diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json index 9a0f2ad49..6265e01a1 100644 --- a/packages/ethereum-types/CHANGELOG.json +++ b/packages/ethereum-types/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.1.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.1.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.1.4", "changes": [ { diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md index 1d27757f3..c1857495d 100644 --- a/packages/ethereum-types/CHANGELOG.md +++ b/packages/ethereum-types/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.6 - _January 15, 2019_ + + * Dependencies updated + +## v1.1.5 - _January 11, 2019_ + + * Dependencies updated + ## v1.1.4 - _December 13, 2018_ * Dependencies updated diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index 69ae64c2b..953b323c6 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-types", - "version": "1.1.4", + "version": "1.1.6", "engines": { "node": ">=6.12" }, @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/ethereum-types/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", "tslint": "5.11.0", diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index 9430fdc98..a8dcfd68a 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -306,6 +306,8 @@ export interface TraceParams { disableMemory?: boolean; disableStack?: boolean; disableStorage?: boolean; + tracer?: string; + timeout?: string; } export type OutputField = diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index adf27655e..d8f2591a4 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.1.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.1.0", "changes": [ { diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index 45cee1ce3..7df8b5ab3 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.1.1 - _January 11, 2019_ + + * Dependencies updated + ## v1.1.0 - _January 9, 2019_ * Add support for MultiAssetProxy (#1363) diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index a38dcc1c3..d882aba76 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,6 +1,6 @@ { "name": "@0x/fill-scenarios", - "version": "1.1.0", + "version": "1.1.2", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/lodash": "4.14.104", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", @@ -28,15 +28,15 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/base-contract": "^3.0.11", - "@0x/contract-artifacts": "^1.2.0", - "@0x/order-utils": "^3.1.0", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", - "ethereum-types": "^1.1.4", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/base-contract": "^3.0.13", + "@0x/contract-artifacts": "^1.3.0", + "@0x/order-utils": "^3.1.2", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5" }, diff --git a/packages/instant/CHANGELOG.json b/packages/instant/CHANGELOG.json index db187140f..537670584 100644 --- a/packages/instant/CHANGELOG.json +++ b/packages/instant/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "2.0.0", + "changes": [ + { + "note": "Renamed ActionTypes enum members to PascalCase to conform with tslint enum-naming rule", + "pr": 1474 + } + ] + }, + { "timestamp": 1542821676, "version": "1.0.1", "changes": [ diff --git a/packages/instant/package.json b/packages/instant/package.json index 0888fc6a6..36409ef3d 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -1,6 +1,6 @@ { "name": "@0x/instant", - "version": "1.0.5", + "version": "1.0.7", "engines": { "node": ">=6.12" }, @@ -41,18 +41,18 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/asset-buyer": "^3.0.5", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/assert": "^1.0.23", + "@0x/asset-buyer": "^4.0.1", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "bowser": "^1.9.4", "copy-to-clipboard": "^3.0.8", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "lodash": "^4.17.5", "polished": "^2.2.0", "react": "^16.5.2", @@ -65,7 +65,7 @@ "ts-optchain": "^0.1.1" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@static/discharge": "https://github.com/0xProject/discharge.git", "@types/enzyme": "^3.1.14", "@types/enzyme-adapter-react-16": "^1.0.3", diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts index 9d7a61fc7..ca0be543b 100644 --- a/packages/instant/src/redux/actions.ts +++ b/packages/instant/src/redux/actions.ts @@ -21,57 +21,56 @@ function createAction<T extends string, P>(type: T, data?: P): PlainAction<T> | } export enum ActionTypes { - SET_ACCOUNT_STATE_LOADING = 'SET_ACCOUNT_STATE_LOADING', - SET_ACCOUNT_STATE_LOCKED = 'SET_ACCOUNT_STATE_LOCKED', - SET_ACCOUNT_STATE_READY = 'SET_ACCOUNT_STATE_READY', - UPDATE_ACCOUNT_ETH_BALANCE = 'UPDATE_ACCOUNT_ETH_BALANCE', - UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE', - UPDATE_SELECTED_ASSET_UNIT_AMOUNT = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT', - SET_BUY_ORDER_STATE_NONE = 'SET_BUY_ORDER_STATE_NONE', - SET_BUY_ORDER_STATE_VALIDATING = 'SET_BUY_ORDER_STATE_VALIDATING', - SET_BUY_ORDER_STATE_PROCESSING = 'SET_BUY_ORDER_STATE_PROCESSING', - SET_BUY_ORDER_STATE_FAILURE = 'SET_BUY_ORDER_STATE_FAILURE', - SET_BUY_ORDER_STATE_SUCCESS = 'SET_BUY_ORDER_STATE_SUCCESS', - UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE', - UPDATE_SELECTED_ASSET = 'UPDATE_SELECTED_ASSET', - SET_AVAILABLE_ASSETS = 'SET_AVAILABLE_ASSETS', - SET_QUOTE_REQUEST_STATE_PENDING = 'SET_QUOTE_REQUEST_STATE_PENDING', - SET_QUOTE_REQUEST_STATE_FAILURE = 'SET_QUOTE_REQUEST_STATE_FAILURE', - SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE', - HIDE_ERROR = 'HIDE_ERROR', - CLEAR_ERROR = 'CLEAR_ERROR', - RESET_AMOUNT = 'RESET_AMOUNT', - OPEN_STANDARD_SLIDING_PANEL = 'OPEN_STANDARD_SLIDING_PANEL', - CLOSE_STANDARD_SLIDING_PANEL = 'CLOSE_STANDARD_SLIDING_PANEL', - UPDATE_BASE_CURRENCY = 'UPDATE_BASE_CURRENCY', + SetAccountStateLoading = 'SET_ACCOUNT_STATE_LOADING', + SetAccountStateLocked = 'SET_ACCOUNT_STATE_LOCKED', + SetAccountStateReady = 'SET_ACCOUNT_STATE_READY', + UpdateAccountEthBalance = 'UPDATE_ACCOUNT_ETH_BALANCE', + UpdateEthUsdPrice = 'UPDATE_ETH_USD_PRICE', + UpdateSelectedAssetUnitAmount = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT', + SetBuyOrderStateNone = 'SET_BUY_ORDER_STATE_NONE', + SetBuyOrderStateValidating = 'SET_BUY_ORDER_STATE_VALIDATING', + SetBuyOrderStateProcessing = 'SET_BUY_ORDER_STATE_PROCESSING', + SetBuyOrderStateFailure = 'SET_BUY_ORDER_STATE_FAILURE', + SetBuyOrderStateSuccess = 'SET_BUY_ORDER_STATE_SUCCESS', + UpdateLatestBuyQuote = 'UPDATE_LATEST_BUY_QUOTE', + UpdateSelectedAsset = 'UPDATE_SELECTED_ASSET', + SetAvailableAssets = 'SET_AVAILABLE_ASSETS', + SetQuoteRequestStatePending = 'SET_QUOTE_REQUEST_STATE_PENDING', + SetQuoteRequestStateFailure = 'SET_QUOTE_REQUEST_STATE_FAILURE', + SetErrorMessage = 'SET_ERROR_MESSAGE', + HideError = 'HIDE_ERROR', + ClearError = 'CLEAR_ERROR', + ResetAmount = 'RESET_AMOUNT', + OpenStandardSlidingPanel = 'OPEN_STANDARD_SLIDING_PANEL', + CloseStandardSlidingPanel = 'CLOSE_STANDARD_SLIDING_PANEL', + UpdateBaseCurrency = 'UPDATE_BASE_CURRENCY', } export const actions = { - setAccountStateLoading: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOADING), - setAccountStateLocked: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOCKED), - setAccountStateReady: (address: string) => createAction(ActionTypes.SET_ACCOUNT_STATE_READY, address), + setAccountStateLoading: () => createAction(ActionTypes.SetAccountStateLoading), + setAccountStateLocked: () => createAction(ActionTypes.SetAccountStateLocked), + setAccountStateReady: (address: string) => createAction(ActionTypes.SetAccountStateReady, address), updateAccountEthBalance: (addressAndBalance: AddressAndEthBalanceInWei) => - createAction(ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE, addressAndBalance), - updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price), - updateSelectedAssetAmount: (amount?: BigNumber) => - createAction(ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT, amount), - setBuyOrderStateNone: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_NONE), - setBuyOrderStateValidating: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_VALIDATING), + createAction(ActionTypes.UpdateAccountEthBalance, addressAndBalance), + updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UpdateEthUsdPrice, price), + updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UpdateSelectedAssetUnitAmount, amount), + setBuyOrderStateNone: () => createAction(ActionTypes.SetBuyOrderStateNone), + setBuyOrderStateValidating: () => createAction(ActionTypes.SetBuyOrderStateValidating), setBuyOrderStateProcessing: (txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => - createAction(ActionTypes.SET_BUY_ORDER_STATE_PROCESSING, { txHash, startTimeUnix, expectedEndTimeUnix }), - setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_FAILURE, txHash), - setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_SUCCESS, txHash), - updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote), - updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UPDATE_SELECTED_ASSET, asset), - setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SET_AVAILABLE_ASSETS, availableAssets), - setQuoteRequestStatePending: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING), - setQuoteRequestStateFailure: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE), - setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SET_ERROR_MESSAGE, errorMessage), - hideError: () => createAction(ActionTypes.HIDE_ERROR), - clearError: () => createAction(ActionTypes.CLEAR_ERROR), - resetAmount: () => createAction(ActionTypes.RESET_AMOUNT), + createAction(ActionTypes.SetBuyOrderStateProcessing, { txHash, startTimeUnix, expectedEndTimeUnix }), + setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateFailure, txHash), + setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateSuccess, txHash), + updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UpdateLatestBuyQuote, buyQuote), + updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UpdateSelectedAsset, asset), + setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SetAvailableAssets, availableAssets), + setQuoteRequestStatePending: () => createAction(ActionTypes.SetQuoteRequestStatePending), + setQuoteRequestStateFailure: () => createAction(ActionTypes.SetQuoteRequestStateFailure), + setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SetErrorMessage, errorMessage), + hideError: () => createAction(ActionTypes.HideError), + clearError: () => createAction(ActionTypes.ClearError), + resetAmount: () => createAction(ActionTypes.ResetAmount), openStandardSlidingPanel: (content: StandardSlidingPanelContent) => - createAction(ActionTypes.OPEN_STANDARD_SLIDING_PANEL, content), - closeStandardSlidingPanel: () => createAction(ActionTypes.CLOSE_STANDARD_SLIDING_PANEL), - updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UPDATE_BASE_CURRENCY, baseCurrency), + createAction(ActionTypes.OpenStandardSlidingPanel, content), + closeStandardSlidingPanel: () => createAction(ActionTypes.CloseStandardSlidingPanel), + updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UpdateBaseCurrency, baseCurrency), }; diff --git a/packages/instant/src/redux/analytics_middleware.ts b/packages/instant/src/redux/analytics_middleware.ts index a86a16b1a..4b4d30213 100644 --- a/packages/instant/src/redux/analytics_middleware.ts +++ b/packages/instant/src/redux/analytics_middleware.ts @@ -21,7 +21,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction const curAccount = curState.providerState.account; switch (nextAction.type) { - case ActionTypes.SET_ACCOUNT_STATE_READY: + case ActionTypes.SetAccountStateReady: if (curAccount.state === AccountState.Ready) { const didJustTurnReady = prevAccount.state !== AccountState.Ready; const didJustUpdateAddress = @@ -38,13 +38,13 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction } } break; - case ActionTypes.SET_ACCOUNT_STATE_LOCKED: + case ActionTypes.SetAccountStateLocked: if (prevAccount.state !== AccountState.Locked && curAccount.state === AccountState.Locked) { // if we are moving from account not locked to account locked, track `Account - Locked` analytics.trackAccountLocked(); } break; - case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: + case ActionTypes.UpdateAccountEthBalance: if ( curAccount.state === AccountState.Ready && curAccount.ethBalanceInWei && @@ -58,7 +58,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction analytics.addEventProperties({ ethBalanceInUnitAmount }); } break; - case ActionTypes.UPDATE_SELECTED_ASSET: + case ActionTypes.UpdateSelectedAsset: const selectedAsset = curState.selectedAsset; if (selectedAsset) { const assetName = selectedAsset.metaData.name; @@ -79,7 +79,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction analytics.addEventProperties(selectedAssetEventProperties); } break; - case ActionTypes.SET_AVAILABLE_ASSETS: + case ActionTypes.SetAvailableAssets: const availableAssets = curState.availableAssets; if (availableAssets) { analytics.addEventProperties({ @@ -87,19 +87,19 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction }); } break; - case ActionTypes.OPEN_STANDARD_SLIDING_PANEL: + case ActionTypes.OpenStandardSlidingPanel: const openSlidingContent = curState.standardSlidingPanelSettings.content; if (openSlidingContent === StandardSlidingPanelContent.InstallWallet) { analytics.trackInstallWalletModalOpened(); } break; - case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL: + case ActionTypes.CloseStandardSlidingPanel: const closeSlidingContent = curState.standardSlidingPanelSettings.content; if (closeSlidingContent === StandardSlidingPanelContent.InstallWallet) { analytics.trackInstallWalletModalClosed(); } break; - case ActionTypes.UPDATE_BASE_CURRENCY: + case ActionTypes.UpdateBaseCurrency: analytics.trackBaseCurrencyChanged(curState.baseCurrency); analytics.addEventProperties({ baseCurrency: curState.baseCurrency }); } diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index 8c13c9c72..0d8bb4b05 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -72,11 +72,11 @@ export const DEFAULT_STATE: DefaultState = { export const createReducer = (initialState: State) => { const reducer = (state: State = initialState, action: Action): State => { switch (action.type) { - case ActionTypes.SET_ACCOUNT_STATE_LOADING: + case ActionTypes.SetAccountStateLoading: return reduceStateWithAccount(state, LOADING_ACCOUNT); - case ActionTypes.SET_ACCOUNT_STATE_LOCKED: + case ActionTypes.SetAccountStateLocked: return reduceStateWithAccount(state, LOCKED_ACCOUNT); - case ActionTypes.SET_ACCOUNT_STATE_READY: { + case ActionTypes.SetAccountStateReady: { const address = action.data; let newAccount: AccountReady = { state: AccountState.Ready, @@ -91,7 +91,7 @@ export const createReducer = (initialState: State) => { } return reduceStateWithAccount(state, newAccount); } - case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: { + case ActionTypes.UpdateAccountEthBalance: { const { address, ethBalanceInWei } = action.data; const currentAccount = state.providerState.account; if (currentAccount.state !== AccountState.Ready || currentAccount.address !== address) { @@ -104,17 +104,17 @@ export const createReducer = (initialState: State) => { return reduceStateWithAccount(state, newAccount); } } - case ActionTypes.UPDATE_ETH_USD_PRICE: + case ActionTypes.UpdateEthUsdPrice: return { ...state, ethUsdPrice: action.data, }; - case ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT: + case ActionTypes.UpdateSelectedAssetUnitAmount: return { ...state, selectedAssetUnitAmount: action.data, }; - case ActionTypes.UPDATE_LATEST_BUY_QUOTE: + case ActionTypes.UpdateLatestBuyQuote: const newBuyQuoteIfExists = action.data; const shouldUpdate = _.isUndefined(newBuyQuoteIfExists) || doesBuyQuoteMatchState(newBuyQuoteIfExists, state); @@ -127,29 +127,29 @@ export const createReducer = (initialState: State) => { } else { return state; } - case ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING: + case ActionTypes.SetQuoteRequestStatePending: return { ...state, latestBuyQuote: undefined, quoteRequestState: AsyncProcessState.Pending, }; - case ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE: + case ActionTypes.SetQuoteRequestStateFailure: return { ...state, latestBuyQuote: undefined, quoteRequestState: AsyncProcessState.Failure, }; - case ActionTypes.SET_BUY_ORDER_STATE_NONE: + case ActionTypes.SetBuyOrderStateNone: return { ...state, buyOrderState: { processState: OrderProcessState.None }, }; - case ActionTypes.SET_BUY_ORDER_STATE_VALIDATING: + case ActionTypes.SetBuyOrderStateValidating: return { ...state, buyOrderState: { processState: OrderProcessState.Validating }, }; - case ActionTypes.SET_BUY_ORDER_STATE_PROCESSING: + case ActionTypes.SetBuyOrderStateProcessing: const processingData = action.data; const { startTimeUnix, expectedEndTimeUnix } = processingData; return { @@ -163,7 +163,7 @@ export const createReducer = (initialState: State) => { }, }, }; - case ActionTypes.SET_BUY_ORDER_STATE_FAILURE: + case ActionTypes.SetBuyOrderStateFailure: const failureTxHash = action.data; if ('txHash' in state.buyOrderState) { if (state.buyOrderState.txHash === failureTxHash) { @@ -179,7 +179,7 @@ export const createReducer = (initialState: State) => { } } return state; - case ActionTypes.SET_BUY_ORDER_STATE_SUCCESS: + case ActionTypes.SetBuyOrderStateSuccess: const successTxHash = action.data; if ('txHash' in state.buyOrderState) { if (state.buyOrderState.txHash === successTxHash) { @@ -195,29 +195,29 @@ export const createReducer = (initialState: State) => { } } return state; - case ActionTypes.SET_ERROR_MESSAGE: + case ActionTypes.SetErrorMessage: return { ...state, latestErrorMessage: action.data, latestErrorDisplayStatus: DisplayStatus.Present, }; - case ActionTypes.HIDE_ERROR: + case ActionTypes.HideError: return { ...state, latestErrorDisplayStatus: DisplayStatus.Hidden, }; - case ActionTypes.CLEAR_ERROR: + case ActionTypes.ClearError: return { ...state, latestErrorMessage: undefined, latestErrorDisplayStatus: DisplayStatus.Hidden, }; - case ActionTypes.UPDATE_SELECTED_ASSET: + case ActionTypes.UpdateSelectedAsset: return { ...state, selectedAsset: action.data, }; - case ActionTypes.RESET_AMOUNT: + case ActionTypes.ResetAmount: return { ...state, latestBuyQuote: undefined, @@ -225,12 +225,12 @@ export const createReducer = (initialState: State) => { buyOrderState: { processState: OrderProcessState.None }, selectedAssetUnitAmount: undefined, }; - case ActionTypes.SET_AVAILABLE_ASSETS: + case ActionTypes.SetAvailableAssets: return { ...state, availableAssets: action.data, }; - case ActionTypes.OPEN_STANDARD_SLIDING_PANEL: + case ActionTypes.OpenStandardSlidingPanel: return { ...state, standardSlidingPanelSettings: { @@ -238,7 +238,7 @@ export const createReducer = (initialState: State) => { animationState: 'slidIn', }, }; - case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL: + case ActionTypes.CloseStandardSlidingPanel: return { ...state, standardSlidingPanelSettings: { @@ -246,7 +246,7 @@ export const createReducer = (initialState: State) => { animationState: 'slidOut', }, }; - case ActionTypes.UPDATE_BASE_CURRENCY: + case ActionTypes.UpdateBaseCurrency: return { ...state, baseCurrency: action.data, diff --git a/packages/instant/src/style/theme.ts b/packages/instant/src/style/theme.ts index fd3f03c3f..49f3c81e6 100644 --- a/packages/instant/src/style/theme.ts +++ b/packages/instant/src/style/theme.ts @@ -11,7 +11,7 @@ const { } = styledComponents; export type Theme = { [key in ColorOption]: string }; - +// tslint:disable:enum-naming export enum ColorOption { primaryColor = 'primaryColor', black = 'black', diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index f07a407da..606294c93 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -27,8 +27,8 @@ export enum QuoteFetchOrigin { } export enum BaseCurrency { - USD = 'USD', - ETH = 'ETH', + USD = 'USD', // tslint:disable-line:enum-naming + ETH = 'ETH', // tslint:disable-line:enum-naming } export interface SimulatedProgress { @@ -95,7 +95,7 @@ export enum Network { export enum ZeroExInstantError { AssetMetaDataNotAvailable = 'ASSET_META_DATA_NOT_AVAILABLE', - InsufficientETH = 'INSUFFICIENT_ETH', + InsufficientETH = 'INSUFFICIENT_ETH', // tslint:disable-line:enum-naming CouldNotSubmitTransaction = 'COULD_NOT_SUBMIT_TRANSACTION', } @@ -168,7 +168,7 @@ export enum WalletSuggestion { export enum OperatingSystem { Android = 'ANDROID', - iOS = 'IOS', + iOS = 'IOS', // tslint:disable-line:enum-naming Mac = 'MAC', Windows = 'WINDOWS', WindowsPhone = 'WINDOWS_PHONE', diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts index 4faeaaf5a..fa8a72a2c 100644 --- a/packages/instant/src/util/analytics.ts +++ b/packages/instant/src/util/analytics.ts @@ -31,38 +31,38 @@ export const evaluateIfEnabled = (fnCall: () => void) => { }; enum EventNames { - INSTANT_OPENED = 'Instant - Opened', - INSTANT_CLOSED = 'Instant - Closed', - ACCOUNT_LOCKED = 'Account - Locked', - ACCOUNT_READY = 'Account - Ready', - ACCOUNT_UNLOCK_REQUESTED = 'Account - Unlock Requested', - ACCOUNT_UNLOCK_DENIED = 'Account - Unlock Denied', - ACCOUNT_ADDRESS_CHANGED = 'Account - Address Changed', - BASE_CURRENCY_CHANGED = 'Base Currency - Changed', - PAYMENT_METHOD_DROPDOWN_OPENED = 'Payment Method - Dropdown Opened', - PAYMENT_METHOD_OPENED_ETHERSCAN = 'Payment Method - Opened Etherscan', - PAYMENT_METHOD_COPIED_ADDRESS = 'Payment Method - Copied Address', - BUY_NOT_ENOUGH_ETH = 'Buy - Not Enough Eth', - BUY_STARTED = 'Buy - Started', - BUY_SIGNATURE_DENIED = 'Buy - Signature Denied', - BUY_SIMULATION_FAILED = 'Buy - Simulation Failed', - BUY_UNKNOWN_ERROR = 'Buy - Unknown Error', - BUY_TX_SUBMITTED = 'Buy - Tx Submitted', - BUY_TX_SUCCEEDED = 'Buy - Tx Succeeded', - BUY_TX_FAILED = 'Buy - Tx Failed', - USD_PRICE_FETCH_FAILED = 'USD Price - Fetch Failed', - INSTALL_WALLET_CLICKED = 'Install Wallet - Clicked', - INSTALL_WALLET_MODAL_OPENED = 'Install Wallet - Modal - Opened', - INSTALL_WALLET_MODAL_CLICKED_EXPLANATION = 'Install Wallet - Modal - Clicked Explanation', - INSTALL_WALLET_MODAL_CLICKED_GET = 'Install Wallet - Modal - Clicked Get', - INSTALL_WALLET_MODAL_CLOSED = 'Install Wallet - Modal - Closed', - TOKEN_SELECTOR_OPENED = 'Token Selector - Opened', - TOKEN_SELECTOR_CLOSED = 'Token Selector - Closed', - TOKEN_SELECTOR_CHOSE = 'Token Selector - Chose', - TOKEN_SELECTOR_SEARCHED = 'Token Selector - Searched', - TRANSACTION_VIEWED = 'Transaction - Viewed', - QUOTE_FETCHED = 'Quote - Fetched', - QUOTE_ERROR = 'Quote - Error', + InstantOpened = 'Instant - Opened', + InstantClosed = 'Instant - Closed', + AccountLocked = 'Account - Locked', + AccountReady = 'Account - Ready', + AccountUnlockRequested = 'Account - Unlock Requested', + AccountUnlockDenied = 'Account - Unlock Denied', + AccountAddressChanged = 'Account - Address Changed', + BaseCurrencyChanged = 'Base Currency - Changed', + PaymentMethodDropdownOpened = 'Payment Method - Dropdown Opened', + PaymentMethodOpenedEtherscan = 'Payment Method - Opened Etherscan', + PaymentMethodCopiedAddress = 'Payment Method - Copied Address', + BuyNotEnoughEth = 'Buy - Not Enough Eth', + BuyStarted = 'Buy - Started', + BuySignatureDenied = 'Buy - Signature Denied', + BuySimulationFailed = 'Buy - Simulation Failed', + BuyUnknownError = 'Buy - Unknown Error', + BuyTxSubmitted = 'Buy - Tx Submitted', + BuyTxSucceeded = 'Buy - Tx Succeeded', + BuyTxFailed = 'Buy - Tx Failed', + UsdPriceFetchFailed = 'USD Price - Fetch Failed', + InstallWalletClicked = 'Install Wallet - Clicked', + InstallWalletModalOpened = 'Install Wallet - Modal - Opened', + InstallWalletModalClickedExplanation = 'Install Wallet - Modal - Clicked Explanation', + InstallWalletModalClickedGet = 'Install Wallet - Modal - Clicked Get', + InstallWalletModalClosed = 'Install Wallet - Modal - Closed', + TokenSelectorOpened = 'Token Selector - Opened', + TokenSelectorClosed = 'Token Selector - Closed', + TokenSelectorChose = 'Token Selector - Chose', + TokenSelectorSearched = 'Token Selector - Searched', + TransactionViewed = 'Transaction - Viewed', + QuoteFetched = 'Quote - Fetched', + QuoteError = 'Quote - Error', } const track = (eventName: EventNames, eventProperties: EventProperties = {}): void => { @@ -125,7 +125,7 @@ export interface AnalyticsEventOptions { baseCurrency?: string; } export enum TokenSelectorClosedVia { - ClickedX = 'Clicked X', + ClickedX = 'Clicked X', // tslint:disable-line:enum-naming TokenChose = 'Token Chose', } export const analytics = { @@ -169,80 +169,80 @@ export const analytics = { }; return eventOptions; }, - trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED), - trackInstantClosed: trackingEventFnWithoutPayload(EventNames.INSTANT_CLOSED), - trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED), - trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.ACCOUNT_READY)({ address }), - trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_REQUESTED), - trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_DENIED), + trackInstantOpened: trackingEventFnWithoutPayload(EventNames.InstantOpened), + trackInstantClosed: trackingEventFnWithoutPayload(EventNames.InstantClosed), + trackAccountLocked: trackingEventFnWithoutPayload(EventNames.AccountLocked), + trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.AccountReady)({ address }), + trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.AccountUnlockRequested), + trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.AccountUnlockDenied), trackAccountAddressChanged: (address: string) => - trackingEventFnWithPayload(EventNames.ACCOUNT_ADDRESS_CHANGED)({ address }), + trackingEventFnWithPayload(EventNames.AccountAddressChanged)({ address }), trackBaseCurrencyChanged: (currencyChangedTo: BaseCurrency) => - trackingEventFnWithPayload(EventNames.BASE_CURRENCY_CHANGED)({ currencyChangedTo }), - trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_DROPDOWN_OPENED), - trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_OPENED_ETHERSCAN), - trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_COPIED_ADDRESS), + trackingEventFnWithPayload(EventNames.BaseCurrencyChanged)({ currencyChangedTo }), + trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PaymentMethodDropdownOpened), + trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PaymentMethodOpenedEtherscan), + trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PaymentMethodCopiedAddress), trackBuyNotEnoughEth: (buyQuote: BuyQuote) => - trackingEventFnWithPayload(EventNames.BUY_NOT_ENOUGH_ETH)(buyQuoteEventProperties(buyQuote)), + trackingEventFnWithPayload(EventNames.BuyNotEnoughEth)(buyQuoteEventProperties(buyQuote)), trackBuyStarted: (buyQuote: BuyQuote) => - trackingEventFnWithPayload(EventNames.BUY_STARTED)(buyQuoteEventProperties(buyQuote)), + trackingEventFnWithPayload(EventNames.BuyStarted)(buyQuoteEventProperties(buyQuote)), trackBuySignatureDenied: (buyQuote: BuyQuote) => - trackingEventFnWithPayload(EventNames.BUY_SIGNATURE_DENIED)(buyQuoteEventProperties(buyQuote)), + trackingEventFnWithPayload(EventNames.BuySignatureDenied)(buyQuoteEventProperties(buyQuote)), trackBuySimulationFailed: (buyQuote: BuyQuote) => - trackingEventFnWithPayload(EventNames.BUY_SIMULATION_FAILED)(buyQuoteEventProperties(buyQuote)), + trackingEventFnWithPayload(EventNames.BuySimulationFailed)(buyQuoteEventProperties(buyQuote)), trackBuyUnknownError: (buyQuote: BuyQuote, errorMessage: string) => - trackingEventFnWithPayload(EventNames.BUY_UNKNOWN_ERROR)({ + trackingEventFnWithPayload(EventNames.BuyUnknownError)({ ...buyQuoteEventProperties(buyQuote), errorMessage, }), trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => - trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({ + trackingEventFnWithPayload(EventNames.BuyTxSubmitted)({ ...buyQuoteEventProperties(buyQuote), txHash, expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix, }), trackBuyTxSucceeded: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => - trackingEventFnWithPayload(EventNames.BUY_TX_SUCCEEDED)({ + trackingEventFnWithPayload(EventNames.BuyTxSucceeded)({ ...buyQuoteEventProperties(buyQuote), txHash, expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix, actualTxTimeMs: new Date().getTime() - startTimeUnix, }), trackBuyTxFailed: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => - trackingEventFnWithPayload(EventNames.BUY_TX_FAILED)({ + trackingEventFnWithPayload(EventNames.BuyTxFailed)({ ...buyQuoteEventProperties(buyQuote), txHash, expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix, actualTxTimeMs: new Date().getTime() - startTimeUnix, }), trackInstallWalletClicked: (walletSuggestion: WalletSuggestion) => - trackingEventFnWithPayload(EventNames.INSTALL_WALLET_CLICKED)({ walletSuggestion }), + trackingEventFnWithPayload(EventNames.InstallWalletClicked)({ walletSuggestion }), trackInstallWalletModalClickedExplanation: trackingEventFnWithoutPayload( - EventNames.INSTALL_WALLET_MODAL_CLICKED_EXPLANATION, + EventNames.InstallWalletModalClickedExplanation, ), - trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLICKED_GET), - trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_OPENED), - trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLOSED), - trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TOKEN_SELECTOR_OPENED), + trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClickedGet), + trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.InstallWalletModalOpened), + trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClosed), + trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TokenSelectorOpened), trackTokenSelectorClosed: (closedVia: TokenSelectorClosedVia) => - trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CLOSED)({ closedVia }), + trackingEventFnWithPayload(EventNames.TokenSelectorClosed)({ closedVia }), trackTokenSelectorChose: (payload: { assetName: string; assetData: string }) => - trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CHOSE)(payload), + trackingEventFnWithPayload(EventNames.TokenSelectorChose)(payload), trackTokenSelectorSearched: (searchText: string) => - trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_SEARCHED)({ searchText }), + trackingEventFnWithPayload(EventNames.TokenSelectorSearched)({ searchText }), trackTransactionViewed: (orderProcesState: OrderProcessState) => - trackingEventFnWithPayload(EventNames.TRANSACTION_VIEWED)({ orderState: orderProcesState }), + trackingEventFnWithPayload(EventNames.TransactionViewed)({ orderState: orderProcesState }), trackQuoteFetched: (buyQuote: BuyQuote, fetchOrigin: QuoteFetchOrigin) => - trackingEventFnWithPayload(EventNames.QUOTE_FETCHED)({ + trackingEventFnWithPayload(EventNames.QuoteFetched)({ ...buyQuoteEventProperties(buyQuote), fetchOrigin, }), trackQuoteError: (errorMessage: string, assetBuyAmount: BigNumber, fetchOrigin: QuoteFetchOrigin) => { - trackingEventFnWithPayload(EventNames.QUOTE_ERROR)({ + trackingEventFnWithPayload(EventNames.QuoteError)({ errorMessage, assetBuyAmount: assetBuyAmount.toString(), fetchOrigin, }); }, - trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.USD_PRICE_FETCH_FAILED), + trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.UsdPriceFetchFailed), }; diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index 8a9def75f..1388b4dca 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "2.1.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "2.1.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "2.1.5", "changes": [ diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index 6d3373336..4e562d9e8 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.7 - _January 15, 2019_ + + * Dependencies updated + +## v2.1.6 - _January 11, 2019_ + + * Dependencies updated + ## v2.1.5 - _January 9, 2019_ * Dependencies updated diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 5103486db..cd515a747 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0x/json-schemas", - "version": "2.1.5", + "version": "2.1.7", "engines": { "node": ">=6.12" }, @@ -39,14 +39,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { - "@0x/typescript-typings": "^3.0.6", + "@0x/typescript-typings": "^3.0.8", "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", - "@0x/utils": "^2.1.1", + "@0x/tslint-config": "^2.0.2", + "@0x/utils": "^3.0.1", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 6812ff823..accdd2949 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0x/metacoin", - "version": "0.0.33", + "version": "0.0.35", "engines": { "node": ">=6.12" }, @@ -29,28 +29,28 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@0x/abi-gen": "^1.0.20", - "@0x/abi-gen-templates": "^1.0.1", - "@0x/base-contract": "^3.0.11", - "@0x/sol-coverage": "^1.0.0", - "@0x/sol-profiler": "^1.0.0", - "@0x/sol-trace": "^1.0.0", - "@0x/subproviders": "^2.1.9", - "@0x/tslint-config": "^2.0.0", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/abi-gen": "^1.0.22", + "@0x/abi-gen-templates": "^1.0.2", + "@0x/base-contract": "^3.0.13", + "@0x/sol-coverage": "^1.0.2", + "@0x/sol-profiler": "^1.0.2", + "@0x/sol-trace": "^1.0.2", + "@0x/subproviders": "^2.1.11", + "@0x/tslint-config": "^2.0.2", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/mocha": "^5.2.2", "copyfiles": "^2.0.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5", "run-s": "^0.0.0" }, "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/sol-compiler": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/sol-compiler": "^2.0.2", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 5e7c89290..5962a9886 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,5 +1,24 @@ [ { + "version": "2.4.0", + "changes": [ + { + "note": "Added migrations for `MultiAssetProxy` contract", + "pr": 1503 + } + ], + "timestamp": 1547561734 + }, + { + "timestamp": 1547225310, + "version": "2.3.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.3.0", "changes": [ { diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index 420769187..6c9a84018 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.4.0 - _January 15, 2019_ + + * Added migrations for `MultiAssetProxy` contract (#1503) + +## v2.3.1 - _January 11, 2019_ + + * Dependencies updated + ## v2.3.0 - _January 9, 2019_ * Added migrations for Dutch Auction contract (#1465) diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 774236ab4..3ca4e8d6b 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0x/migrations", - "version": "2.3.0", + "version": "2.4.0", "engines": { "node": ">=6.12" }, @@ -35,9 +35,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/tslint-config": "^2.0.0", - "@0x/types": "^1.5.0", + "@0x/dev-utils": "^1.0.24", + "@0x/tslint-config": "^2.0.2", + "@0x/types": "^1.5.2", "@types/yargs": "^10.0.0", "make-promises-safe": "^1.1.0", "npm-run-all": "^4.1.2", @@ -48,18 +48,18 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/base-contract": "^3.0.11", - "@0x/contract-addresses": "^2.1.0", - "@0x/contract-artifacts": "^1.2.0", - "@0x/order-utils": "^3.1.0", - "@0x/sol-compiler": "^2.0.0", - "@0x/subproviders": "^2.1.9", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/base-contract": "^3.0.13", + "@0x/contract-addresses": "^2.2.0", + "@0x/contract-artifacts": "^1.3.0", + "@0x/order-utils": "^3.1.2", + "@0x/sol-compiler": "^2.0.2", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@ledgerhq/hw-app-eth": "^4.3.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethers": "~4.0.4", "lodash": "^4.17.5" }, diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 99d1719f1..e0f245017 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -18,6 +18,8 @@ import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info'; */ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial<TxData>): Promise<ContractAddresses> { const web3Wrapper = new Web3Wrapper(provider); + const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); + const owner = accounts[0]; // Proxies const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -50,22 +52,35 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial zrxAssetData, ); - // Multisigs - const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); - const owners = [accounts[0], accounts[1]]; - const confirmationsRequired = new BigNumber(2); - const secondsRequired = new BigNumber(0); - const owner = accounts[0]; + // Dummy ERC20 tokens + for (const token of erc20TokenInfo) { + const totalSupply = new BigNumber(1000000000000000000000000000); + // tslint:disable-next-line:no-unused-variable + const dummyErc20Token = await wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync( + artifacts.DummyERC20Token, + provider, + txDefaults, + token.name, + token.symbol, + token.decimals, + totalSupply, + ); + } - // AssetProxyOwner - const assetProxyOwner = await wrappers.AssetProxyOwnerContract.deployFrom0xArtifactAsync( - artifacts.AssetProxyOwner, + // ERC721 + // tslint:disable-next-line:no-unused-variable + const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync( + artifacts.DummyERC721Token, + provider, + txDefaults, + erc721TokenInfo[0].name, + erc721TokenInfo[0].symbol, + ); + + const multiAssetProxy = await wrappers.MultiAssetProxyContract.deployFrom0xArtifactAsync( + artifacts.MultiAssetProxy, provider, txDefaults, - owners, - [erc20Proxy.address, erc721Proxy.address], - confirmationsRequired, - secondsRequired, ); await web3Wrapper.awaitTransactionSuccessAsync( @@ -74,20 +89,33 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial }), ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner, }), ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { + await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner, }), ); + + // MultiAssetProxy await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { + await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { from: owner, }), ); + await web3Wrapper.awaitTransactionSuccessAsync( + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { + from: owner, + }), + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc20Proxy.address), + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc721Proxy.address), + ); // Register the Asset Proxies to the Exchange await web3Wrapper.awaitTransactionSuccessAsync( @@ -96,30 +124,8 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial await web3Wrapper.awaitTransactionSuccessAsync( await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address), ); - - // Dummy ERC20 tokens - for (const token of erc20TokenInfo) { - const totalSupply = new BigNumber(1000000000000000000000000000); - // tslint:disable-next-line:no-unused-variable - const dummyErc20Token = await wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, - provider, - txDefaults, - token.name, - token.symbol, - token.decimals, - totalSupply, - ); - } - - // ERC721 - // tslint:disable-next-line:no-unused-variable - const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC721Token, - provider, - txDefaults, - erc721TokenInfo[0].name, - erc721TokenInfo[0].symbol, + await web3Wrapper.awaitTransactionSuccessAsync( + await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address), ); // Forwarder @@ -149,6 +155,39 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial exchange.address, ); + // Multisigs + const owners = [accounts[0], accounts[1]]; + const confirmationsRequired = new BigNumber(2); + const secondsRequired = new BigNumber(0); + + // AssetProxyOwner + const assetProxyOwner = await wrappers.AssetProxyOwnerContract.deployFrom0xArtifactAsync( + artifacts.AssetProxyOwner, + provider, + txDefaults, + owners, + [erc20Proxy.address, erc721Proxy.address, multiAssetProxy.address], + confirmationsRequired, + secondsRequired, + ); + + // Transfer Ownership to the Asset Proxy Owner + await web3Wrapper.awaitTransactionSuccessAsync( + await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { + from: owner, + }), + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { + from: owner, + }), + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { + from: owner, + }), + ); + // Fund the Forwarder with ZRX const zrxDecimals = await zrxToken.decimals.callAsync(); const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals); @@ -156,7 +195,7 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial await zrxToken.transfer.sendTransactionAsync(forwarder.address, zrxForwarderAmount, txDefaults), ); - return { + const contractAddresses = { erc20Proxy: erc20Proxy.address, erc721Proxy: erc721Proxy.address, zrxToken: zrxToken.address, @@ -167,6 +206,8 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial orderValidator: orderValidator.address, dutchAuction: dutchAuction.address, }; + + return contractAddresses; } let _cachedContractAddresses: ContractAddresses; diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 3286b8412..e18aa1d2f 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0x/monorepo-scripts", - "version": "1.0.16", + "version": "1.0.18", "engines": { "node": ">=6.12" }, @@ -47,7 +47,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/utils": "^2.0.8", + "@0x/utils": "^3.0.1", "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 6cda7a1e6..ace3656c4 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.1.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.1.0", "changes": [ { diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index eb36616d1..c82458f2e 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.1.2 - _January 15, 2019_ + + * Dependencies updated + +## v3.1.1 - _January 11, 2019_ + + * Dependencies updated + ## v3.1.0 - _January 9, 2019_ * Use new ABI encoder, add encoding/decoding logic for MultiAsset assetData, and add information to return values in orderStateUtils (#1363) diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index e59ea664f..bdcbd2dfc 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/order-utils", - "version": "3.1.0", + "version": "3.1.2", "engines": { "node": ">=6.12" }, @@ -35,8 +35,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/tslint-config": "^2.0.2", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "chai": "^4.0.1", @@ -53,18 +53,18 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/assert": "^1.0.21", - "@0x/base-contract": "^3.0.11", - "@0x/contract-artifacts": "^1.2.0", - "@0x/json-schemas": "^2.1.5", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/assert": "^1.0.23", + "@0x/base-contract": "^3.0.13", + "@0x/contract-artifacts": "^1.3.0", + "@0x/json-schemas": "^2.1.7", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/node": "*", "bn.js": "^4.11.8", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index e98a36719..bb77feee0 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "2.4.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "2.4.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.4.0", "changes": [ { diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index 600b9fa6f..e5f4833cd 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.4.2 - _January 15, 2019_ + + * Dependencies updated + +## v2.4.1 - _January 11, 2019_ + + * Dependencies updated + ## v2.4.0 - _January 9, 2019_ * Add support for `MultiAssetProxy` (#1363) diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 5919759dd..4cae45604 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0x/order-watcher", - "version": "2.4.0", + "version": "2.4.2", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -33,10 +33,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/migrations": "^2.3.0", - "@0x/subproviders": "^2.1.9", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/migrations": "^2.4.0", + "@0x/subproviders": "^2.1.11", + "@0x/tslint-config": "^2.0.2", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -58,21 +58,21 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.1.0", - "@0x/assert": "^1.0.21", - "@0x/base-contract": "^3.0.11", - "@0x/contract-addresses": "^2.1.0", - "@0x/contract-artifacts": "^1.2.0", - "@0x/contract-wrappers": "^4.2.0", - "@0x/fill-scenarios": "^1.1.0", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/abi-gen-wrappers": "^2.2.0", + "@0x/assert": "^1.0.23", + "@0x/base-contract": "^3.0.13", + "@0x/contract-addresses": "^2.2.0", + "@0x/contract-artifacts": "^1.3.0", + "@0x/contract-wrappers": "^5.0.0", + "@0x/fill-scenarios": "^1.1.2", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "bintrees": "^1.0.2", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-blockstream": "6.0.0", "ethers": "~4.0.4", "lodash": "^4.17.5", diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json index 47150300d..988dd8b74 100644 --- a/packages/pipeline/package.json +++ b/packages/pipeline/package.json @@ -1,6 +1,6 @@ { "name": "@0x/pipeline", - "version": "1.0.3", + "version": "1.0.5", "private": true, "description": "Data pipeline for offline analysis", "scripts": { @@ -27,7 +27,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/axios": "^0.14.0", "@types/ramda": "^0.25.38", "chai": "^4.1.2", @@ -39,23 +39,23 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/connect": "^3.0.11", - "@0x/contract-addresses": "^2.1.0", - "@0x/contract-artifacts": "^1.2.0", + "@0x/connect": "^3.0.13", + "@0x/contract-addresses": "^2.2.0", + "@0x/contract-artifacts": "^1.3.0", "@0x/contract-wrappers": "^3.0.0", - "@0x/dev-utils": "^1.0.22", - "@0x/order-utils": "^3.1.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/dev-utils": "^1.0.24", + "@0x/order-utils": "^3.1.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/dockerode": "^2.5.9", "@types/p-limit": "^2.0.0", "async-parallel": "^1.2.3", "axios": "^0.18.0", "bottleneck": "^2.13.2", "dockerode": "^2.5.7", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "pg": "^7.5.0", "prettier": "^1.15.3", "ramda": "^0.25.0", diff --git a/packages/pipeline/src/parsers/copper/index.ts b/packages/pipeline/src/parsers/copper/index.ts index 6c0c5abd5..07da66d10 100644 --- a/packages/pipeline/src/parsers/copper/index.ts +++ b/packages/pipeline/src/parsers/copper/index.ts @@ -44,8 +44,8 @@ export interface CopperActivityParentResponse { // custom activity types export enum CopperActivityTypeCategory { - user = 'user', - system = 'system', + User = 'user', + System = 'system', } export interface CopperActivityTypeResponse { id: number; @@ -90,7 +90,7 @@ export enum CopperCustomFieldType { Date = 'Date', Checkbox = 'Checkbox', Float = 'Float', - URL = 'URL', + URL = 'URL', // tslint:disable-line:enum-naming Percentage = 'Percentage', Currency = 'Currency', Connect = 'Connect', diff --git a/packages/pipeline/src/scripts/pull_competing_dex_trades.ts b/packages/pipeline/src/scripts/pull_competing_dex_trades.ts index 1478d5615..14644bb2e 100644 --- a/packages/pipeline/src/scripts/pull_competing_dex_trades.ts +++ b/packages/pipeline/src/scripts/pull_competing_dex_trades.ts @@ -1,7 +1,8 @@ -// tslint:disable:no-console import 'reflect-metadata'; import { Connection, ConnectionOptions, createConnection, Repository } from 'typeorm'; +import { logUtils } from '@0x/utils'; + import { BloxySource } from '../data_sources/bloxy'; import { DexTrade } from '../entities'; import * as ormConfig from '../ormconfig'; @@ -27,14 +28,14 @@ async function getAndSaveTradesAsync(): Promise<void> { const bloxySource = new BloxySource(apiKey); const tradesRepository = connection.getRepository(DexTrade); const lastSeenTimestamp = await getLastSeenTimestampAsync(tradesRepository); - console.log(`Last seen timestamp: ${lastSeenTimestamp === 0 ? 'none' : lastSeenTimestamp}`); - console.log('Getting latest dex trades...'); + logUtils.log(`Last seen timestamp: ${lastSeenTimestamp === 0 ? 'none' : lastSeenTimestamp}`); + logUtils.log('Getting latest dex trades...'); const rawTrades = await bloxySource.getDexTradesAsync(lastSeenTimestamp); - console.log(`Parsing ${rawTrades.length} trades...`); + logUtils.log(`Parsing ${rawTrades.length} trades...`); const trades = parseBloxyTrades(rawTrades); - console.log(`Saving ${trades.length} trades...`); + logUtils.log(`Saving ${trades.length} trades...`); await tradesRepository.save(trades, { chunk: Math.ceil(trades.length / BATCH_SAVE_SIZE) }); - console.log('Done saving trades.'); + logUtils.log('Done saving trades.'); } async function getLastSeenTimestampAsync(tradesRepository: Repository<DexTrade>): Promise<number> { diff --git a/packages/pipeline/src/scripts/pull_copper.ts b/packages/pipeline/src/scripts/pull_copper.ts index 69814f209..5e4a6a643 100644 --- a/packages/pipeline/src/scripts/pull_copper.ts +++ b/packages/pipeline/src/scripts/pull_copper.ts @@ -1,7 +1,8 @@ -// tslint:disable:no-console import * as R from 'ramda'; import { Connection, ConnectionOptions, createConnection, Repository } from 'typeorm'; +import { logUtils } from '@0x/utils'; + import { CopperEndpoint, CopperSearchParams, CopperSource } from '../data_sources/copper'; import { CopperActivity, CopperActivityType, CopperCustomField, CopperLead, CopperOpportunity } from '../entities'; import * as ormConfig from '../ormconfig'; @@ -43,14 +44,14 @@ let connection: Connection; async function fetchAndSaveLeadsAsync(source: CopperSource): Promise<void> { const repository = connection.getRepository(CopperLead); const startTime = await getMaxAsync(connection, 'date_modified', 'raw.copper_leads'); - console.log(`Fetching Copper leads starting from ${startTime}...`); + logUtils.log(`Fetching Copper leads starting from ${startTime}...`); await fetchAndSaveAsync(CopperEndpoint.Leads, source, startTime, {}, parseLeads, repository); } async function fetchAndSaveOpportunitiesAsync(source: CopperSource): Promise<void> { const repository = connection.getRepository(CopperOpportunity); const startTime = await getMaxAsync(connection, 'date_modified', 'raw.copper_opportunities'); - console.log(`Fetching Copper opportunities starting from ${startTime}...`); + logUtils.log(`Fetching Copper opportunities starting from ${startTime}...`); await fetchAndSaveAsync( CopperEndpoint.Opportunities, source, @@ -67,7 +68,7 @@ async function fetchAndSaveActivitiesAsync(source: CopperSource): Promise<void> const searchParams = { minimum_activity_date: Math.floor(startTime / ONE_SECOND), }; - console.log(`Fetching Copper activities starting from ${startTime}...`); + logUtils.log(`Fetching Copper activities starting from ${startTime}...`); await fetchAndSaveAsync(CopperEndpoint.Activities, source, startTime, searchParams, parseActivities, repository); } @@ -97,7 +98,7 @@ async function fetchAndSaveAsync<T extends CopperSearchResponse, E>( const numPages = await source.fetchNumberOfPagesAsync(endpoint); try { for (let i = numPages; i > 0; i--) { - console.log(`Fetching page ${i}/${numPages} of ${endpoint}...`); + logUtils.log(`Fetching page ${i}/${numPages} of ${endpoint}...`); const raw = await source.fetchSearchResultsAsync<T>(endpoint, { ...searchParams, page_number: i, @@ -108,21 +109,21 @@ async function fetchAndSaveAsync<T extends CopperSearchResponse, E>( saved += newRecords.length; } } catch (err) { - console.log(`Error fetching ${endpoint}, stopping: ${err.stack}`); + logUtils.log(`Error fetching ${endpoint}, stopping: ${err.stack}`); } finally { - console.log(`Saved ${saved} items from ${endpoint}, done.`); + logUtils.log(`Saved ${saved} items from ${endpoint}, done.`); } } async function fetchAndSaveActivityTypesAsync(source: CopperSource): Promise<void> { - console.log(`Fetching Copper activity types...`); + logUtils.log(`Fetching Copper activity types...`); const activityTypes = await source.fetchActivityTypesAsync(); const repository = connection.getRepository(CopperActivityType); await repository.save(parseActivityTypes(activityTypes)); } async function fetchAndSaveCustomFieldsAsync(source: CopperSource): Promise<void> { - console.log(`Fetching Copper custom fields...`); + logUtils.log(`Fetching Copper custom fields...`); const customFields = await source.fetchCustomFieldsAsync(); const repository = connection.getRepository(CopperCustomField); await repository.save(parseCustomFields(customFields)); diff --git a/packages/pipeline/src/scripts/pull_exchange_events.ts b/packages/pipeline/src/scripts/pull_exchange_events.ts index e98fc6629..f8ce4038d 100644 --- a/packages/pipeline/src/scripts/pull_exchange_events.ts +++ b/packages/pipeline/src/scripts/pull_exchange_events.ts @@ -1,6 +1,6 @@ -// tslint:disable:no-console import { web3Factory } from '@0x/dev-utils'; import { Web3ProviderEngine } from '@0x/subproviders'; +import { logUtils } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import R = require('ramda'); import 'reflect-metadata'; @@ -32,38 +32,38 @@ let connection: Connection; })().catch(handleError); async function getFillEventsAsync(eventsSource: ExchangeEventsSource, endBlock: number): Promise<void> { - console.log('Checking existing fill events...'); + logUtils.log('Checking existing fill events...'); const repository = connection.getRepository(ExchangeFillEvent); const startBlock = await getStartBlockAsync(repository); - console.log(`Getting fill events starting at ${startBlock}...`); + logUtils.log(`Getting fill events starting at ${startBlock}...`); const eventLogs = await eventsSource.getFillEventsAsync(startBlock, endBlock); - console.log('Parsing fill events...'); + logUtils.log('Parsing fill events...'); const events = parseExchangeFillEvents(eventLogs); - console.log(`Retrieved and parsed ${events.length} total fill events.`); + logUtils.log(`Retrieved and parsed ${events.length} total fill events.`); await saveEventsAsync(startBlock === EXCHANGE_START_BLOCK, repository, events); } async function getCancelEventsAsync(eventsSource: ExchangeEventsSource, endBlock: number): Promise<void> { - console.log('Checking existing cancel events...'); + logUtils.log('Checking existing cancel events...'); const repository = connection.getRepository(ExchangeCancelEvent); const startBlock = await getStartBlockAsync(repository); - console.log(`Getting cancel events starting at ${startBlock}...`); + logUtils.log(`Getting cancel events starting at ${startBlock}...`); const eventLogs = await eventsSource.getCancelEventsAsync(startBlock, endBlock); - console.log('Parsing cancel events...'); + logUtils.log('Parsing cancel events...'); const events = parseExchangeCancelEvents(eventLogs); - console.log(`Retrieved and parsed ${events.length} total cancel events.`); + logUtils.log(`Retrieved and parsed ${events.length} total cancel events.`); await saveEventsAsync(startBlock === EXCHANGE_START_BLOCK, repository, events); } async function getCancelUpToEventsAsync(eventsSource: ExchangeEventsSource, endBlock: number): Promise<void> { - console.log('Checking existing CancelUpTo events...'); + logUtils.log('Checking existing CancelUpTo events...'); const repository = connection.getRepository(ExchangeCancelUpToEvent); const startBlock = await getStartBlockAsync(repository); - console.log(`Getting CancelUpTo events starting at ${startBlock}...`); + logUtils.log(`Getting CancelUpTo events starting at ${startBlock}...`); const eventLogs = await eventsSource.getCancelUpToEventsAsync(startBlock, endBlock); - console.log('Parsing CancelUpTo events...'); + logUtils.log('Parsing CancelUpTo events...'); const events = parseExchangeCancelUpToEvents(eventLogs); - console.log(`Retrieved and parsed ${events.length} total CancelUpTo events.`); + logUtils.log(`Retrieved and parsed ${events.length} total CancelUpTo events.`); await saveEventsAsync(startBlock === EXCHANGE_START_BLOCK, repository, events); } @@ -72,7 +72,7 @@ const tableNameRegex = /^[a-zA-Z_]*$/; async function getStartBlockAsync<T extends ExchangeEvent>(repository: Repository<T>): Promise<number> { const fillEventCount = await repository.count(); if (fillEventCount === 0) { - console.log(`No existing ${repository.metadata.name}s found.`); + logUtils.log(`No existing ${repository.metadata.name}s found.`); return EXCHANGE_START_BLOCK; } const tableName = repository.metadata.tableName; @@ -91,7 +91,7 @@ async function saveEventsAsync<T extends ExchangeEvent>( repository: Repository<T>, events: T[], ): Promise<void> { - console.log(`Saving ${repository.metadata.name}s...`); + logUtils.log(`Saving ${repository.metadata.name}s...`); if (isInitialPull) { // Split data into numChunks pieces of maximum size BATCH_SAVE_SIZE // each. @@ -104,7 +104,7 @@ async function saveEventsAsync<T extends ExchangeEvent>( await saveIndividuallyWithFallbackAsync(repository, events); } const totalEvents = await repository.count(); - console.log(`Done saving events. There are now ${totalEvents} total ${repository.metadata.name}s.`); + logUtils.log(`Done saving events. There are now ${totalEvents} total ${repository.metadata.name}s.`); } async function saveIndividuallyWithFallbackAsync<T extends ExchangeEvent>( diff --git a/packages/pipeline/src/scripts/pull_missing_blocks.ts b/packages/pipeline/src/scripts/pull_missing_blocks.ts index ced9d99eb..345ea38fe 100644 --- a/packages/pipeline/src/scripts/pull_missing_blocks.ts +++ b/packages/pipeline/src/scripts/pull_missing_blocks.ts @@ -1,5 +1,6 @@ -// tslint:disable:no-console import { web3Factory } from '@0x/dev-utils'; +import { logUtils } from '@0x/utils'; + import * as Parallel from 'async-parallel'; import R = require('ramda'); import 'reflect-metadata'; @@ -47,7 +48,7 @@ interface MissingBlocksResponse { async function getAllMissingBlocksAsync(web3Source: Web3Source, tableName: string): Promise<void> { const blocksRepository = connection.getRepository(Block); while (true) { - console.log(`Checking for missing blocks in ${tableName}...`); + logUtils.log(`Checking for missing blocks in ${tableName}...`); const blockNumbers = await getMissingBlockNumbersAsync(tableName); if (blockNumbers.length === 0) { // There are no more missing blocks. We're done. @@ -56,7 +57,7 @@ async function getAllMissingBlocksAsync(web3Source: Web3Source, tableName: strin await getAndSaveBlocksAsync(web3Source, blocksRepository, blockNumbers); } const totalBlocks = await blocksRepository.count(); - console.log(`Done saving blocks for ${tableName}. There are now ${totalBlocks} total blocks.`); + logUtils.log(`Done saving blocks for ${tableName}. There are now ${totalBlocks} total blocks.`); } async function getMissingBlockNumbersAsync(tableName: string): Promise<number[]> { @@ -68,7 +69,7 @@ async function getMissingBlockNumbersAsync(tableName: string): Promise<number[]> )) as MissingBlocksResponse[]; const blockNumberStrings = R.pluck('block_number', response); const blockNumbers = R.map(parseInt, blockNumberStrings); - console.log(`Found ${blockNumbers.length} missing blocks.`); + logUtils.log(`Found ${blockNumbers.length} missing blocks.`); return blockNumbers; } @@ -77,14 +78,14 @@ async function getAndSaveBlocksAsync( blocksRepository: Repository<Block>, blockNumbers: number[], ): Promise<void> { - console.log(`Getting block data for ${blockNumbers.length} blocks...`); + logUtils.log(`Getting block data for ${blockNumbers.length} blocks...`); Parallel.setConcurrency(MAX_CONCURRENCY); const rawBlocks = await Parallel.map(blockNumbers, async (blockNumber: number) => web3Source.getBlockInfoAsync(blockNumber), ); - console.log(`Parsing ${rawBlocks.length} blocks...`); + logUtils.log(`Parsing ${rawBlocks.length} blocks...`); const blocks = R.map(parseBlock, rawBlocks); - console.log(`Saving ${blocks.length} blocks...`); + logUtils.log(`Saving ${blocks.length} blocks...`); await blocksRepository.save(blocks, { chunk: Math.ceil(blocks.length / BATCH_SAVE_SIZE) }); - console.log('Done saving this batch of blocks'); + logUtils.log('Done saving this batch of blocks'); } diff --git a/packages/pipeline/src/scripts/pull_ohlcv_cryptocompare.ts b/packages/pipeline/src/scripts/pull_ohlcv_cryptocompare.ts index d44eb5cc6..caac7b9d4 100644 --- a/packages/pipeline/src/scripts/pull_ohlcv_cryptocompare.ts +++ b/packages/pipeline/src/scripts/pull_ohlcv_cryptocompare.ts @@ -1,6 +1,7 @@ -// tslint:disable:no-console import { Connection, ConnectionOptions, createConnection, Repository } from 'typeorm'; +import { logUtils } from '@0x/utils'; + import { CryptoCompareOHLCVSource } from '../data_sources/ohlcv_external/crypto_compare'; import { OHLCVExternal } from '../entities'; import * as ormConfig from '../ormconfig'; @@ -24,14 +25,14 @@ let connection: Connection; const jobTime = new Date().getTime(); const tradingPairs = await fetchOHLCVTradingPairsAsync(connection, SOURCE_NAME, EARLIEST_BACKFILL_TIME); - console.log(`Starting ${tradingPairs.length} job(s) to scrape Crypto Compare for OHLCV records...`); + logUtils.log(`Starting ${tradingPairs.length} job(s) to scrape Crypto Compare for OHLCV records...`); const fetchAndSavePromises = tradingPairs.map(async pair => { const pairs = source.generateBackfillIntervals(pair); return fetchAndSaveAsync(source, repository, jobTime, pairs); }); await Promise.all(fetchAndSavePromises); - console.log(`Finished scraping OHLCV records from Crypto Compare, exiting...`); + logUtils.log(`Finished scraping OHLCV records from Crypto Compare, exiting...`); process.exit(0); })().catch(handleError); @@ -60,7 +61,7 @@ async function fetchAndSaveAsync( } try { const records = await source.getHourlyOHLCVAsync(pair); - console.log(`Retrieved ${records.length} records for ${JSON.stringify(pair)}`); + logUtils.log(`Retrieved ${records.length} records for ${JSON.stringify(pair)}`); if (records.length > 0) { const metadata: OHLCVMetadata = { exchange: source.defaultExchange, @@ -75,7 +76,7 @@ async function fetchAndSaveAsync( } i++; } catch (err) { - console.log(`Error scraping OHLCVRecords, stopping task for ${JSON.stringify(pair)} [${err}]`); + logUtils.log(`Error scraping OHLCVRecords, stopping task for ${JSON.stringify(pair)} [${err}]`); break; } } @@ -90,6 +91,6 @@ async function saveRecordsAsync(repository: Repository<OHLCVExternal>, records: new Date(records[records.length - 1].endTime), ]; - console.log(`Saving ${records.length} records to ${repository.metadata.name}... ${JSON.stringify(metadata)}`); + logUtils.log(`Saving ${records.length} records to ${repository.metadata.name}... ${JSON.stringify(metadata)}`); await repository.save(records); } diff --git a/packages/pipeline/src/scripts/pull_radar_relay_orders.ts b/packages/pipeline/src/scripts/pull_radar_relay_orders.ts index 03fc764f2..8e8720803 100644 --- a/packages/pipeline/src/scripts/pull_radar_relay_orders.ts +++ b/packages/pipeline/src/scripts/pull_radar_relay_orders.ts @@ -1,5 +1,6 @@ -// tslint:disable:no-console import { HttpClient } from '@0x/connect'; +import { logUtils } from '@0x/utils'; + import * as R from 'ramda'; import 'reflect-metadata'; import { Connection, ConnectionOptions, createConnection, EntityManager } from 'typeorm'; @@ -21,13 +22,13 @@ let connection: Connection; })().catch(handleError); async function getOrderbookAsync(): Promise<void> { - console.log('Getting all orders...'); + logUtils.log('Getting all orders...'); const connectClient = new HttpClient(RADAR_RELAY_URL); const rawOrders = await connectClient.getOrdersAsync({ perPage: ORDERS_PER_PAGE, }); - console.log(`Got ${rawOrders.records.length} orders.`); - console.log('Parsing orders...'); + logUtils.log(`Got ${rawOrders.records.length} orders.`); + logUtils.log('Parsing orders...'); // Parse the sra orders, then add source url to each. const orders = R.pipe( parseSraOrders, @@ -35,7 +36,7 @@ async function getOrderbookAsync(): Promise<void> { )(rawOrders); // Save all the orders and update the observed time stamps in a single // transaction. - console.log('Saving orders and updating timestamps...'); + logUtils.log('Saving orders and updating timestamps...'); const observedTimestamp = Date.now(); await connection.transaction( async (manager: EntityManager): Promise<void> => { diff --git a/packages/pipeline/src/scripts/pull_trusted_tokens.ts b/packages/pipeline/src/scripts/pull_trusted_tokens.ts index 5906deee6..8afb3e052 100644 --- a/packages/pipeline/src/scripts/pull_trusted_tokens.ts +++ b/packages/pipeline/src/scripts/pull_trusted_tokens.ts @@ -1,6 +1,8 @@ import 'reflect-metadata'; import { Connection, ConnectionOptions, createConnection } from 'typeorm'; +import { logUtils } from '@0x/utils'; + import { MetamaskTrustedTokenMeta, TrustedTokenSource, ZeroExTrustedTokenMeta } from '../data_sources/trusted_tokens'; import { TokenMetadata } from '../entities'; import * as ormConfig from '../ormconfig'; @@ -22,31 +24,25 @@ let connection: Connection; })().catch(handleError); async function getMetamaskTrustedTokensAsync(): Promise<void> { - // tslint:disable-next-line:no-console - console.log('Getting latest metamask trusted tokens list ...'); + logUtils.log('Getting latest metamask trusted tokens list ...'); const trustedTokensRepository = connection.getRepository(TokenMetadata); const trustedTokensSource = new TrustedTokenSource<Map<string, MetamaskTrustedTokenMeta>>( METAMASK_TRUSTED_TOKENS_URL, ); const resp = await trustedTokensSource.getTrustedTokenMetaAsync(); const trustedTokens = parseMetamaskTrustedTokens(resp); - // tslint:disable-next-line:no-console - console.log('Saving metamask trusted tokens list'); + logUtils.log('Saving metamask trusted tokens list'); await trustedTokensRepository.save(trustedTokens); - // tslint:disable-next-line:no-console - console.log('Done saving metamask trusted tokens.'); + logUtils.log('Done saving metamask trusted tokens.'); } async function getZeroExTrustedTokensAsync(): Promise<void> { - // tslint:disable-next-line:no-console - console.log('Getting latest 0x trusted tokens list ...'); + logUtils.log('Getting latest 0x trusted tokens list ...'); const trustedTokensRepository = connection.getRepository(TokenMetadata); const trustedTokensSource = new TrustedTokenSource<ZeroExTrustedTokenMeta[]>(ZEROEX_TRUSTED_TOKENS_URL); const resp = await trustedTokensSource.getTrustedTokenMetaAsync(); const trustedTokens = parseZeroExTrustedTokens(resp); - // tslint:disable-next-line:no-console - console.log('Saving metamask trusted tokens list'); + logUtils.log('Saving metamask trusted tokens list'); await trustedTokensRepository.save(trustedTokens); - // tslint:disable-next-line:no-console - console.log('Done saving metamask trusted tokens.'); + logUtils.log('Done saving metamask trusted tokens.'); } diff --git a/packages/pipeline/src/scripts/update_relayer_info.ts b/packages/pipeline/src/scripts/update_relayer_info.ts index 41d29b385..910a0157c 100644 --- a/packages/pipeline/src/scripts/update_relayer_info.ts +++ b/packages/pipeline/src/scripts/update_relayer_info.ts @@ -1,7 +1,8 @@ -// tslint:disable:no-console import 'reflect-metadata'; import { Connection, ConnectionOptions, createConnection } from 'typeorm'; +import { logUtils } from '@0x/utils'; + import { RelayerRegistrySource } from '../data_sources/relayer-registry'; import { Relayer } from '../entities'; import * as ormConfig from '../ormconfig'; @@ -22,12 +23,12 @@ let connection: Connection; })().catch(handleError); async function getRelayersAsync(): Promise<void> { - console.log('Getting latest relayer info...'); + logUtils.log('Getting latest relayer info...'); const relayerRepository = connection.getRepository(Relayer); const relayerSource = new RelayerRegistrySource(RELAYER_REGISTRY_URL); const relayersResp = await relayerSource.getRelayerInfoAsync(); const relayers = parseRelayers(relayersResp); - console.log('Saving relayer info...'); + logUtils.log('Saving relayer info...'); await relayerRepository.save(relayers); - console.log('Done saving relayer info.'); + logUtils.log('Done saving relayer info.'); } diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index 02608f18d..101da65c7 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.25", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.24", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.23", "changes": [ diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index 01f987645..5ec82b5be 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.25 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.24 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.23 - _January 9, 2019_ * Dependencies updated diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 7cd0ae55a..f8f2b6276 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0x/react-docs", - "version": "1.0.23", + "version": "1.0.25", "engines": { "node": ">=6.12" }, @@ -24,8 +24,8 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/tslint-config": "^2.0.2", "@types/compare-versions": "^3.0.0", "@types/styled-components": "4.0.0", "make-promises-safe": "^1.1.0", @@ -34,9 +34,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/react-shared": "^1.1.0", - "@0x/types": "^1.5.0", - "@0x/utils": "^2.1.1", + "@0x/react-shared": "^1.1.2", + "@0x/types": "^1.5.2", + "@0x/utils": "^3.0.1", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", @@ -47,13 +47,13 @@ "compare-versions": "^3.0.1", "lodash": "^4.17.5", "material-ui": "^0.20.0", - "react": "^16.4.2", - "react-dom": "^16.4.2", + "react": "^16.5.2", + "react-dom": "^16.5.2", "react-markdown": "^3.2.2", "react-scroll": "0xproject/react-scroll#pr-330-and-replace-state", "react-tooltip": "^3.2.7", "semver": "5.5.0", - "styled-components": "^3.3.0" + "styled-components": "^4.0.1" }, "publishConfig": { "access": "public" diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index 23217137f..a6d2c4fa0 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.1.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.1.0", "changes": [ { diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index a8f2764dd..e1a5df403 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.1.1 - _January 11, 2019_ + + * Dependencies updated + ## v1.1.0 - _January 9, 2019_ * Change implementation to use react-router-dom NavLink instead of Link. Expose `activeStyle` prop. (#1448) diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 5754e238b..47d36ca66 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0x/react-shared", - "version": "1.1.0", + "version": "1.1.2", "engines": { "node": ">=6.12" }, @@ -25,15 +25,15 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/tslint-config": "^2.0.2", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", "tslint": "^5.9.1", "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^1.5.0", + "@0x/types": "^1.5.2", "@material-ui/core": "^3.0.1", "@types/is-mobile": "0.3.0", "@types/lodash": "4.14.104", @@ -50,13 +50,13 @@ "is-mobile": "^0.2.2", "lodash": "^4.17.5", "material-ui": "^0.20.0", - "react": "^16.4.2", - "react-dom": "^16.4.2", - "react-highlight": "0xproject/react-highlight#2f40a42e0a3f0ad126f9f42d505b97b603fc7162", + "react": "^16.5.2", + "react-dom": "^16.5.2", + "react-highlight": "0xproject/react-highlight#699ac4d9529e33520bff4b9bd9c624d21efbba75", "react-markdown": "^3.2.2", "react-router-dom": "^4.1.1", "react-scroll": "0xproject/react-scroll#pr-330-and-replace-state", - "styled-components": "^3.3.0", + "styled-components": "^4.0.1", "valid-url": "^1.0.9" }, "publishConfig": { diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index 246b298ab..d7dd5a454 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index 6ec804c3a..dfcec1fa7 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v2.0.1 - _January 11, 2019_ + + * Dependencies updated + ## v2.0.0 - _January 9, 2019_ * Add sol-compiler watch mode with -w flag (#1461) diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 6c9435bcd..26c8e8833 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-compiler", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -42,8 +42,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/tslint-config": "^2.0.0", + "@0x/dev-utils": "^1.0.24", + "@0x/tslint-config": "^2.0.2", "@types/chokidar": "^1.7.5", "@types/mkdirp": "^0.5.2", "@types/pluralize": "^0.0.29", @@ -67,17 +67,17 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/json-schemas": "^2.1.5", - "@0x/sol-resolver": "^1.2.1", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/assert": "^1.0.23", + "@0x/json-schemas": "^2.1.7", + "@0x/sol-resolver": "^1.2.3", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", "chokidar": "^2.0.4", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json index 223400eae..8157d441e 100644 --- a/packages/sol-coverage/CHANGELOG.json +++ b/packages/sol-coverage/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.0.0", "changes": [ { diff --git a/packages/sol-coverage/CHANGELOG.md b/packages/sol-coverage/CHANGELOG.md new file mode 100644 index 000000000..ac09a1bbf --- /dev/null +++ b/packages/sol-coverage/CHANGELOG.md @@ -0,0 +1,18 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.1 - _January 11, 2019_ + + * Dependencies updated + +## v1.0.0 - _Invalid date_ + + * Initial release as a separate package. For historical entries see @0x/sol-tracing-utils (#1492) diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json index 7dc764efd..efe91cf2b 100644 --- a/packages/sol-coverage/package.json +++ b/packages/sol-coverage/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-coverage", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -29,14 +29,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md", "dependencies": { - "@0x/subproviders": "^2.1.8", - "@0x/sol-tracing-utils": "^2.1.16", - "@0x/typescript-typings": "^3.0.6", - "ethereum-types": "^1.1.4", + "@0x/sol-tracing-utils": "^4.0.0", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "ethereum-types": "^1.1.6", "lodash": "^4.17.5" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/node": "*", "npm-run-all": "^4.1.2", "nyc": "^11.0.1", diff --git a/packages/sol-coverage/src/coverage_subprovider.ts b/packages/sol-coverage/src/coverage_subprovider.ts index e6b546c4a..d03963ed6 100644 --- a/packages/sol-coverage/src/coverage_subprovider.ts +++ b/packages/sol-coverage/src/coverage_subprovider.ts @@ -74,19 +74,19 @@ export const coverageHandler: SingleFileSubtraceHandler = ( let sourceRanges = _.map(subtrace, structLog => pcToSourceRange[structLog.pc]); sourceRanges = _.compact(sourceRanges); // Some PC's don't map to a source range and we just ignore them. - // By default lodash does a shallow object comparasion. We JSON.stringify them and compare as strings. + // By default lodash does a shallow object comparison. We JSON.stringify them and compare as strings. sourceRanges = _.uniqBy(sourceRanges, s => JSON.stringify(s)); // We don't care if one PC was covered multiple times within a single transaction sourceRanges = _.filter(sourceRanges, sourceRange => sourceRange.fileName === absoluteFileName); const branchCoverage: BranchCoverage = {}; const branchIds = _.keys(coverageEntriesDescription.branchMap); for (const branchId of branchIds) { const branchDescription = coverageEntriesDescription.branchMap[branchId]; - const isBranchCoveredByBranchIndex = _.map(branchDescription.locations, location => { + const branchIndexToIsBranchCovered = _.map(branchDescription.locations, location => { const isBranchCovered = _.some(sourceRanges, range => utils.isRangeInside(range.location, location)); const timesBranchCovered = Number(isBranchCovered); return timesBranchCovered; }); - branchCoverage[branchId] = isBranchCoveredByBranchIndex; + branchCoverage[branchId] = branchIndexToIsBranchCovered; } const statementCoverage: StatementCoverage = {}; const statementIds = _.keys(coverageEntriesDescription.statementMap); diff --git a/packages/sol-coverage/src/index.ts b/packages/sol-coverage/src/index.ts index 97b4ecee6..6a91a3966 100644 --- a/packages/sol-coverage/src/index.ts +++ b/packages/sol-coverage/src/index.ts @@ -4,6 +4,8 @@ export { TruffleArtifactAdapter, AbstractArtifactAdapter, ContractData, + SourceCodes, + Sources, } from '@0x/sol-tracing-utils'; export { diff --git a/packages/sol-doc/CHANGELOG.json b/packages/sol-doc/CHANGELOG.json index 70a769541..f95702ee4 100644 --- a/packages/sol-doc/CHANGELOG.json +++ b/packages/sol-doc/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.14", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.12", "changes": [ diff --git a/packages/sol-doc/CHANGELOG.md b/packages/sol-doc/CHANGELOG.md index 3416662e5..1a60b5f89 100644 --- a/packages/sol-doc/CHANGELOG.md +++ b/packages/sol-doc/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.14 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.13 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.12 - _January 9, 2019_ * Dependencies updated diff --git a/packages/sol-doc/package.json b/packages/sol-doc/package.json index f93abfe49..dee6ef2e5 100644 --- a/packages/sol-doc/package.json +++ b/packages/sol-doc/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-doc", - "version": "1.0.12", + "version": "1.0.14", "description": "Solidity documentation generator", "main": "lib/src/index.js", "types": "lib/src/index.d.js", @@ -25,16 +25,16 @@ "author": "F. Eugene Aumson", "license": "Apache-2.0", "dependencies": { - "@0x/sol-compiler": "^2.0.0", - "@0x/types": "^1.5.0", - "@0x/utils": "^2.1.1", - "ethereum-types": "^1.1.4", + "@0x/sol-compiler": "^2.0.2", + "@0x/types": "^1.5.2", + "@0x/utils": "^3.0.1", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.10", "yargs": "^12.0.2" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "chai": "^4.1.2", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.2", diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json index 223400eae..8157d441e 100644 --- a/packages/sol-profiler/CHANGELOG.json +++ b/packages/sol-profiler/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.0.0", "changes": [ { diff --git a/packages/sol-profiler/CHANGELOG.md b/packages/sol-profiler/CHANGELOG.md new file mode 100644 index 000000000..ac09a1bbf --- /dev/null +++ b/packages/sol-profiler/CHANGELOG.md @@ -0,0 +1,18 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.1 - _January 11, 2019_ + + * Dependencies updated + +## v1.0.0 - _Invalid date_ + + * Initial release as a separate package. For historical entries see @0x/sol-tracing-utils (#1492) diff --git a/packages/sol-profiler/package.json b/packages/sol-profiler/package.json index b85c82ed2..1a89e0a6b 100644 --- a/packages/sol-profiler/package.json +++ b/packages/sol-profiler/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-profiler", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -29,14 +29,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-profiler/README.md", "dependencies": { - "@0x/subproviders": "^2.1.8", - "@0x/typescript-typings": "^3.0.6", - "@0x/sol-tracing-utils": "^2.1.16", - "ethereum-types": "^1.1.4", + "@0x/sol-tracing-utils": "^4.0.0", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "ethereum-types": "^1.1.6", "lodash": "^4.17.5" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/node": "*", "npm-run-all": "^4.1.2", "shx": "^0.2.2", diff --git a/packages/sol-profiler/src/index.ts b/packages/sol-profiler/src/index.ts index 5d4806be4..fcb715d2d 100644 --- a/packages/sol-profiler/src/index.ts +++ b/packages/sol-profiler/src/index.ts @@ -3,6 +3,8 @@ export { SolCompilerArtifactAdapter, TruffleArtifactAdapter, ContractData, + SourceCodes, + Sources, } from '@0x/sol-tracing-utils'; // HACK: ProfilerSubprovider is a hacky way to do profiling using coverage tools. Not production ready diff --git a/packages/sol-profiler/src/profiler_subprovider.ts b/packages/sol-profiler/src/profiler_subprovider.ts index c3ed13ea5..9f195f768 100644 --- a/packages/sol-profiler/src/profiler_subprovider.ts +++ b/packages/sol-profiler/src/profiler_subprovider.ts @@ -63,7 +63,7 @@ export const profilerHandler: SingleFileSubtraceHandler = ( ): Coverage => { const absoluteFileName = contractData.sources[fileIndex]; const profilerEntriesDescription = collectCoverageEntries(contractData.sourceCodes[fileIndex]); - const gasConsumedByStatement: { [statementId: string]: number } = {}; + const statementToGasConsumed: { [statementId: string]: number } = {}; const statementIds = _.keys(profilerEntriesDescription.statementMap); for (const statementId of statementIds) { const statementDescription = profilerEntriesDescription.statementMap[statementId]; @@ -83,14 +83,14 @@ export const profilerHandler: SingleFileSubtraceHandler = ( } }), ); - gasConsumedByStatement[statementId] = totalGasCost; + statementToGasConsumed[statementId] = totalGasCost; } const partialProfilerOutput = { [absoluteFileName]: { ...profilerEntriesDescription, path: absoluteFileName, f: {}, // I's meaningless in profiling context - s: gasConsumedByStatement, + s: statementToGasConsumed, b: {}, // I's meaningless in profiling context }, }; diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index d541dc320..e5f4a8ac1 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.2.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.2.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.2.1", "changes": [ { diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index b03f21b79..a48561cc3 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.2.3 - _January 15, 2019_ + + * Dependencies updated + +## v1.2.2 - _January 11, 2019_ + + * Dependencies updated + ## v1.2.1 - _January 9, 2019_ * Add `absolutePath` to `ContractSource` type (#1461) diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index b33a4f494..0518cde95 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-resolver", - "version": "1.2.1", + "version": "1.2.3", "engines": { "node": ">=6.12" }, @@ -23,15 +23,15 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/resolver/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", "tslint": "5.11.0", "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json index 223400eae..8157d441e 100644 --- a/packages/sol-trace/CHANGELOG.json +++ b/packages/sol-trace/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.0.0", "changes": [ { diff --git a/packages/sol-trace/CHANGELOG.md b/packages/sol-trace/CHANGELOG.md new file mode 100644 index 000000000..ac09a1bbf --- /dev/null +++ b/packages/sol-trace/CHANGELOG.md @@ -0,0 +1,18 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.1 - _January 11, 2019_ + + * Dependencies updated + +## v1.0.0 - _Invalid date_ + + * Initial release as a separate package. For historical entries see @0x/sol-tracing-utils (#1492) diff --git a/packages/sol-trace/package.json b/packages/sol-trace/package.json index 3013be6f9..acae60303 100644 --- a/packages/sol-trace/package.json +++ b/packages/sol-trace/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-trace", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -29,16 +29,16 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace/README.md", "dependencies": { - "@0x/subproviders": "^2.1.8", - "@0x/typescript-typings": "^3.0.6", - "@0x/sol-tracing-utils": "^2.1.16", - "ethereum-types": "^1.1.4", + "@0x/sol-tracing-utils": "^4.0.0", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", "loglevel": "^1.6.1" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/loglevel": "^1.5.3", "@types/node": "*", "npm-run-all": "^4.1.2", diff --git a/packages/sol-trace/src/index.ts b/packages/sol-trace/src/index.ts index 120c0d0a9..61b5d8cb7 100644 --- a/packages/sol-trace/src/index.ts +++ b/packages/sol-trace/src/index.ts @@ -3,6 +3,8 @@ export { TruffleArtifactAdapter, SolCompilerArtifactAdapter, ContractData, + SourceCodes, + Sources, } from '@0x/sol-tracing-utils'; export { RevertTraceSubprovider } from './revert_trace_subprovider'; diff --git a/packages/sol-trace/src/revert_trace_subprovider.ts b/packages/sol-trace/src/revert_trace_subprovider.ts index 31067a402..fa065cfcb 100644 --- a/packages/sol-trace/src/revert_trace_subprovider.ts +++ b/packages/sol-trace/src/revert_trace_subprovider.ts @@ -106,7 +106,8 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider { continue; } - const fileIndex = contractData.sources.indexOf(sourceRange.fileName); + const fileNameToFileIndex = _.invert(contractData.sources); + const fileIndex = _.parseInt(fileNameToFileIndex[sourceRange.fileName]); const sourceSnippet = getSourceRangeSnippet(sourceRange, contractData.sourceCodes[fileIndex]); if (sourceSnippet !== null) { sourceSnippets.push(sourceSnippet); diff --git a/packages/sol-tracing-utils/CHANGELOG.json b/packages/sol-tracing-utils/CHANGELOG.json index 9c0b73169..b470d3e87 100644 --- a/packages/sol-tracing-utils/CHANGELOG.json +++ b/packages/sol-tracing-utils/CHANGELOG.json @@ -1,12 +1,39 @@ [ { + "version": "4.0.0", + "changes": [ + { + "note": "Fix a bug with incorrect parsing of `sourceMaps` due to sources being in an array instead of a map", + "pr": 1498 + }, + { + "note": "Change the types of `ContractData.sources` and `ContractData.sourceCodes` to be objects instead of arrays", + "pr": 1498 + }, + { + "note": "Use custom JS tracer to speed up tracing on clients that support it (e.g., Geth)", + "pr": 1498 + }, + { + "note": "Log errors encountered in `TraceCollectionSubprovider`", + "pr": 1498 + }, + { + "note": "Add support for assembly statements", + "pr": 1498 + } + ], + "timestamp": 1547561734 + }, + { "version": "3.0.0", "changes": [ { "note": "Move out specific tools and leave just the shared parts of the codebase", "pr": 1492 } - ] + ], + "timestamp": 1547225310 }, { "timestamp": 1547040760, diff --git a/packages/sol-tracing-utils/CHANGELOG.md b/packages/sol-tracing-utils/CHANGELOG.md index c2bc3cd01..00d36844c 100644 --- a/packages/sol-tracing-utils/CHANGELOG.md +++ b/packages/sol-tracing-utils/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.0 - _January 15, 2019_ + + * Fix a bug with incorrect parsing of `sourceMaps` due to sources being in an array instead of a map (#1498) + * Change the types of `ContractData.sources` and `ContractData.sourceCodes` to be objects instead of arrays (#1498) + * Use custom JS tracer to speed up tracing on clients that support it (e.g., Geth) (#1498) + * Log errors encountered in `TraceCollectionSubprovider` (#1498) + * Add support for assembly statements (#1498) + +## v3.0.0 - _January 11, 2019_ + + * Move out specific tools and leave just the shared parts of the codebase (#1492) + ## v2.1.17 - _January 9, 2019_ * Dependencies updated diff --git a/packages/sol-tracing-utils/package.json b/packages/sol-tracing-utils/package.json index 9486ab541..e3e52f42c 100644 --- a/packages/sol-tracing-utils/package.json +++ b/packages/sol-tracing-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-tracing-utils", - "version": "2.1.17", + "version": "4.0.0", "engines": { "node": ">=6.12" }, @@ -42,14 +42,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-tracing-utils/README.md", "dependencies": { - "@0x/dev-utils": "^1.0.22", - "@0x/sol-compiler": "^2.0.0", - "@0x/subproviders": "^2.1.9", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/dev-utils": "^1.0.24", + "@0x/sol-compiler": "^2.0.2", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@types/solidity-parser-antlr": "^0.2.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", @@ -61,7 +61,7 @@ "solidity-parser-antlr": "^0.2.12" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/istanbul": "^0.4.30", "@types/loglevel": "^1.5.3", "@types/mkdirp": "^0.5.1", diff --git a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts index 57391abbe..d52587f2c 100644 --- a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts +++ b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts @@ -5,7 +5,7 @@ import * as glob from 'glob'; import * as _ from 'lodash'; import * as path from 'path'; -import { ContractData } from '../types'; +import { ContractData, SourceCodes, Sources } from '../types'; import { AbstractArtifactAdapter } from './abstract_artifact_adapter'; @@ -43,9 +43,14 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { logUtils.warn(`${artifactFileName} doesn't contain bytecode. Skipping...`); continue; } - let sources = _.keys(artifact.sources); - sources = _.map(sources, relativeFilePath => path.resolve(this._sourcesPath, relativeFilePath)); - const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); + const sources: Sources = {}; + const sourceCodes: SourceCodes = {}; + _.map(artifact.sources, (value: { id: number }, relativeFilePath: string) => { + const filePath = path.resolve(this._sourcesPath, relativeFilePath); + const fileContent = fs.readFileSync(filePath).toString(); + sources[value.id] = filePath; + sourceCodes[value.id] = fileContent; + }); const contractData = { sourceCodes, sources, diff --git a/packages/sol-tracing-utils/src/ast_visitor.ts b/packages/sol-tracing-utils/src/ast_visitor.ts index e55cdf6ec..1ac9cd1de 100644 --- a/packages/sol-tracing-utils/src/ast_visitor.ts +++ b/packages/sol-tracing-utils/src/ast_visitor.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as Parser from 'solidity-parser-antlr'; -import { BranchMap, FnMap, LocationByOffset, SingleFileSourceRange, StatementMap } from './types'; +import { BranchMap, FnMap, OffsetToLocation, SingleFileSourceRange, StatementMap } from './types'; export interface CoverageEntriesDescription { fnMap: FnMap; @@ -22,13 +22,13 @@ export class ASTVisitor { private readonly _branchMap: BranchMap = {}; private readonly _modifiersStatementIds: number[] = []; private readonly _statementMap: StatementMap = {}; - private readonly _locationByOffset: LocationByOffset; + private readonly _offsetToLocation: OffsetToLocation; private readonly _ignoreRangesBeginningAt: number[]; // keep track of contract/function ranges that are to be ignored // so we can also ignore any children nodes within the contract/function private readonly _ignoreRangesWithin: Array<[number, number]> = []; - constructor(locationByOffset: LocationByOffset, ignoreRangesBeginningAt: number[] = []) { - this._locationByOffset = locationByOffset; + constructor(offsetToLocation: OffsetToLocation, ignoreRangesBeginningAt: number[] = []) { + this._offsetToLocation = offsetToLocation; this._ignoreRangesBeginningAt = ignoreRangesBeginningAt; } public getCollectedCoverageEntries(): CoverageEntriesDescription { @@ -94,6 +94,39 @@ export class ASTVisitor { public InlineAssemblyStatement(ast: Parser.InlineAssemblyStatement): void { this._visitStatement(ast); } + public AssemblyLocalDefinition(ast: Parser.AssemblyLocalDefinition): void { + this._visitStatement(ast); + } + public AssemblyCall(ast: Parser.AssemblyCall): void { + this._visitStatement(ast); + } + public AssemblyIf(ast: Parser.AssemblyIf): void { + this._visitStatement(ast); + } + public AssemblyBlock(ast: Parser.AssemblyBlock): void { + this._visitStatement(ast); + } + public AssemblyExpression(ast: Parser.AssemblyExpression): void { + this._visitStatement(ast); + } + public AssemblyAssignment(ast: Parser.AssemblyAssignment): void { + this._visitStatement(ast); + } + public LabelDefinition(ast: Parser.LabelDefinition): void { + this._visitStatement(ast); + } + public AssemblySwitch(ast: Parser.AssemblySwitch): void { + this._visitStatement(ast); + } + public AssemblyFunctionDefinition(ast: Parser.AssemblyFunctionDefinition): void { + this._visitStatement(ast); + } + public AssemblyFor(ast: Parser.AssemblyFor): void { + this._visitStatement(ast); + } + public SubAssembly(ast: Parser.SubAssembly): void { + this._visitStatement(ast); + } public BinaryOperation(ast: Parser.BinaryOperation): void { const BRANCHING_BIN_OPS = ['&&', '||']; if (_.includes(BRANCHING_BIN_OPS, ast.operator)) { @@ -136,8 +169,8 @@ export class ASTVisitor { } private _getExpressionRange(ast: Parser.ASTNode): SingleFileSourceRange { const astRange = ast.range as [number, number]; - const start = this._locationByOffset[astRange[0]]; - const end = this._locationByOffset[astRange[1] + 1]; + const start = this._offsetToLocation[astRange[0]]; + const end = this._offsetToLocation[astRange[1] + 1]; const range = { start, end, diff --git a/packages/sol-tracing-utils/src/collect_coverage_entries.ts b/packages/sol-tracing-utils/src/collect_coverage_entries.ts index bdbcd613e..9e3591d74 100644 --- a/packages/sol-tracing-utils/src/collect_coverage_entries.ts +++ b/packages/sol-tracing-utils/src/collect_coverage_entries.ts @@ -3,24 +3,24 @@ import * as _ from 'lodash'; import * as parser from 'solidity-parser-antlr'; import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor'; -import { getLocationByOffset } from './source_maps'; +import { getOffsetToLocation } from './source_maps'; const IGNORE_RE = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm; // Parsing source code for each transaction/code is slow and therefore we cache it -const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {}; +const sourceHashToCoverageEntries: { [sourceHash: string]: CoverageEntriesDescription } = {}; export const collectCoverageEntries = (contractSource: string) => { const sourceHash = ethUtil.sha3(contractSource).toString('hex'); - if (_.isUndefined(coverageEntriesBySourceHash[sourceHash]) && !_.isUndefined(contractSource)) { + if (_.isUndefined(sourceHashToCoverageEntries[sourceHash]) && !_.isUndefined(contractSource)) { const ast = parser.parse(contractSource, { range: true }); - const locationByOffset = getLocationByOffset(contractSource); + const offsetToLocation = getOffsetToLocation(contractSource); const ignoreRangesBegingingAt = gatherRangesToIgnore(contractSource); - const visitor = new ASTVisitor(locationByOffset, ignoreRangesBegingingAt); + const visitor = new ASTVisitor(offsetToLocation, ignoreRangesBegingingAt); parser.visit(ast, visitor); - coverageEntriesBySourceHash[sourceHash] = visitor.getCollectedCoverageEntries(); + sourceHashToCoverageEntries[sourceHash] = visitor.getCollectedCoverageEntries(); } - const coverageEntriesDescription = coverageEntriesBySourceHash[sourceHash]; + const coverageEntriesDescription = sourceHashToCoverageEntries[sourceHash]; return coverageEntriesDescription; }; diff --git a/packages/sol-tracing-utils/src/get_source_range_snippet.ts b/packages/sol-tracing-utils/src/get_source_range_snippet.ts index f578675d3..7aef00fee 100644 --- a/packages/sol-tracing-utils/src/get_source_range_snippet.ts +++ b/packages/sol-tracing-utils/src/get_source_range_snippet.ts @@ -13,7 +13,7 @@ interface ASTInfo { } // Parsing source code for each transaction/code is slow and therefore we cache it -const parsedSourceByHash: { [sourceHash: string]: Parser.ASTNode } = {}; +const hashToParsedSource: { [sourceHash: string]: Parser.ASTNode } = {}; /** * Gets the source range snippet by source range to be used by revert trace. @@ -22,10 +22,10 @@ const parsedSourceByHash: { [sourceHash: string]: Parser.ASTNode } = {}; */ export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: string): SourceSnippet | null { const sourceHash = ethUtil.sha3(sourceCode).toString('hex'); - if (_.isUndefined(parsedSourceByHash[sourceHash])) { - parsedSourceByHash[sourceHash] = Parser.parse(sourceCode, { loc: true }); + if (_.isUndefined(hashToParsedSource[sourceHash])) { + hashToParsedSource[sourceHash] = Parser.parse(sourceCode, { loc: true }); } - const astNode = parsedSourceByHash[sourceHash]; + const astNode = hashToParsedSource[sourceHash]; const visitor = new ASTInfoVisitor(); Parser.visit(astNode, visitor); const astInfo = visitor.getASTInfoForRange(sourceRange); diff --git a/packages/sol-tracing-utils/src/index.ts b/packages/sol-tracing-utils/src/index.ts index 413e5305e..fdf024ae0 100644 --- a/packages/sol-tracing-utils/src/index.ts +++ b/packages/sol-tracing-utils/src/index.ts @@ -22,11 +22,13 @@ export { BranchMap, EvmCallStackEntry, FnMap, - LocationByOffset, + OffsetToLocation, StatementMap, TraceInfoBase, TraceInfoExistingContract, TraceInfoNewContract, + Sources, + SourceCodes, } from './types'; export { collectCoverageEntries } from './collect_coverage_entries'; export { TraceCollector, SingleFileSubtraceHandler } from './trace_collector'; diff --git a/packages/sol-tracing-utils/src/source_maps.ts b/packages/sol-tracing-utils/src/source_maps.ts index af0fb4035..8c17652d9 100644 --- a/packages/sol-tracing-utils/src/source_maps.ts +++ b/packages/sol-tracing-utils/src/source_maps.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { getPcToInstructionIndexMapping } from './instructions'; -import { LocationByOffset, SourceRange } from './types'; +import { OffsetToLocation, SourceCodes, SourceRange, Sources } from './types'; const RADIX = 10; @@ -15,38 +15,41 @@ export interface SourceLocation { * Receives a string with newlines and returns a map of byte offset to LineColumn * @param str A string to process */ -export function getLocationByOffset(str: string): LocationByOffset { - const locationByOffset: LocationByOffset = { 0: { line: 1, column: 0 } }; +export function getOffsetToLocation(str: string): OffsetToLocation { + const offsetToLocation: OffsetToLocation = { 0: { line: 1, column: 0 } }; let currentOffset = 0; for (const char of str.split('')) { - const location = locationByOffset[currentOffset]; + const location = offsetToLocation[currentOffset]; const isNewline = char === '\n'; - locationByOffset[currentOffset + 1] = { + offsetToLocation[currentOffset + 1] = { line: location.line + (isNewline ? 1 : 0), column: isNewline ? 0 : location.column + 1, }; currentOffset++; } - return locationByOffset; + return offsetToLocation; } /** * Parses a sourcemap string. * The solidity sourcemap format is documented here: https://github.com/ethereum/solidity/blob/develop/docs/miscellaneous.rst#source-mappings - * @param sourceCodes sources contents + * @param indexToSourceCode index to source code * @param srcMap source map string * @param bytecodeHex contract bytecode - * @param sources sources file names + * @param indexToSource index to source file path */ export function parseSourceMap( - sourceCodes: string[], + sourceCodes: SourceCodes, srcMap: string, bytecodeHex: string, - sources: string[], + sources: Sources, ): { [programCounter: number]: SourceRange } { const bytecode = Uint8Array.from(Buffer.from(bytecodeHex, 'hex')); const pcToInstructionIndex: { [programCounter: number]: number } = getPcToInstructionIndexMapping(bytecode); - const locationByOffsetByFileIndex = _.map(sourceCodes, s => (_.isUndefined(s) ? {} : getLocationByOffset(s))); + const fileIndexToOffsetToLocation: { [fileIndex: number]: OffsetToLocation } = {}; + _.map(sourceCodes, (sourceCode: string, fileIndex: number) => { + fileIndexToOffsetToLocation[fileIndex] = _.isUndefined(sourceCode) ? {} : getOffsetToLocation(sourceCode); + }); const entries = srcMap.split(';'); let lastParsedEntry: SourceLocation = {} as any; const instructionIndexToSourceRange: { [instructionIndex: number]: SourceRange } = {}; @@ -66,14 +69,18 @@ export function parseSourceMap( length, fileIndex, }; - if (parsedEntry.fileIndex !== -1 && !_.isUndefined(locationByOffsetByFileIndex[parsedEntry.fileIndex])) { + if (parsedEntry.fileIndex !== -1 && !_.isUndefined(fileIndexToOffsetToLocation[parsedEntry.fileIndex])) { + const offsetToLocation = fileIndexToOffsetToLocation[parsedEntry.fileIndex]; const sourceRange = { location: { - start: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset], - end: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset + parsedEntry.length], + start: offsetToLocation[parsedEntry.offset], + end: offsetToLocation[parsedEntry.offset + parsedEntry.length], }, fileName: sources[parsedEntry.fileIndex], }; + if (sourceRange.location.start === undefined || sourceRange.location.end === undefined) { + throw new Error(`Error while processing sourcemap: location out of range in ${sourceRange.fileName}`); + } instructionIndexToSourceRange[i] = sourceRange; } else { // Some assembly code generated by Solidity can't be mapped back to a line of source code. diff --git a/packages/sol-tracing-utils/src/trace.ts b/packages/sol-tracing-utils/src/trace.ts index 770080af3..973452b24 100644 --- a/packages/sol-tracing-utils/src/trace.ts +++ b/packages/sol-tracing-utils/src/trace.ts @@ -4,21 +4,21 @@ import * as _ from 'lodash'; import { utils } from './utils'; -export interface TraceByContractAddress { +export interface ContractAddressToTraces { [contractAddress: string]: StructLog[]; } /** - * Converts linear stack trace to `TraceByContractAddress`. + * Converts linear stack trace to `ContractAddressToTraces`. * @param structLogs stack trace * @param startAddress initial context address */ -export function getTracesByContractAddress(structLogs: StructLog[], startAddress: string): TraceByContractAddress { - const traceByContractAddress: TraceByContractAddress = {}; +export function getContractAddressToTraces(structLogs: StructLog[], startAddress: string): ContractAddressToTraces { + const contractAddressToTraces: ContractAddressToTraces = {}; let currentTraceSegment = []; const addressStack = [startAddress]; if (_.isEmpty(structLogs)) { - return traceByContractAddress; + return contractAddressToTraces; } const normalizedStructLogs = utils.normalizeStructLogs(structLogs); // tslint:disable-next-line:prefer-for-of @@ -45,14 +45,14 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress const nextStructLog = normalizedStructLogs[i + 1]; if (nextStructLog.depth !== structLog.depth) { addressStack.push(newAddress); - traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat( + contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat( currentTraceSegment, ); currentTraceSegment = []; } } else if (utils.isEndOpcode(structLog.op)) { const currentAddress = addressStack.pop() as string; - traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat( + contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat( currentTraceSegment, ); currentTraceSegment = []; @@ -71,7 +71,7 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress logUtils.warn( "Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace", ); - return traceByContractAddress; + return contractAddressToTraces; } else { if (structLog !== _.last(normalizedStructLogs)) { const nextStructLog = normalizedStructLogs[i + 1]; @@ -79,7 +79,7 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress continue; } else if (nextStructLog.depth === structLog.depth - 1) { const currentAddress = addressStack.pop() as string; - traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat( + contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat( currentTraceSegment, ); currentTraceSegment = []; @@ -94,11 +94,11 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress } if (currentTraceSegment.length !== 0) { const currentAddress = addressStack.pop() as string; - traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat( + contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat( currentTraceSegment, ); currentTraceSegment = []; logUtils.warn('Malformed trace. Current trace segment non empty at the end'); } - return traceByContractAddress; + return contractAddressToTraces; } diff --git a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts index 25e38768d..323e1523c 100644 --- a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts +++ b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts @@ -1,5 +1,6 @@ import { BlockchainLifecycle } from '@0x/dev-utils'; import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0x/subproviders'; +import { logUtils } from '@0x/utils'; import { CallDataRPC, marshaller, Web3Wrapper } from '@0x/web3-wrapper'; import { JSONRPCRequestPayload, Provider, TxData } from 'ethereum-types'; import * as _ from 'lodash'; @@ -20,6 +21,23 @@ export interface TraceCollectionSubproviderConfig { shouldCollectGasEstimateTraces: boolean; } +type AsyncFunc = (...args: any[]) => Promise<void>; + +// HACK: This wrapper outputs errors to console even if the promise gets ignored +// we need this because web3-provider-engine does not handle promises in +// the after function of next(after). +function logAsyncErrors(fn: AsyncFunc): AsyncFunc { + async function wrappedAsync(...args: any[]): Promise<void> { + try { + await fn(...args); + } catch (err) { + logUtils.log(err); + throw err; + } + } + return wrappedAsync; +} + // Because there is no notion of a call trace in the Ethereum rpc - we collect them in a rather non-obvious/hacky way. // On each call - we create a snapshot, execute the call as a transaction, get the trace, revert the snapshot. // That allows us to avoid influencing test behaviour. @@ -74,7 +92,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const txData = payload.params[0]; - next(this._onTransactionSentAsync.bind(this, txData)); + next(logAsyncErrors(this._onTransactionSentAsync.bind(this, txData))); } return; @@ -83,7 +101,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const callData = payload.params[0]; - next(this._onCallOrGasEstimateExecutedAsync.bind(this, callData)); + next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, callData))); } return; @@ -92,7 +110,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider { next(); } else { const estimateGasData = payload.params[0]; - next(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData)); + next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData))); } return; diff --git a/packages/sol-tracing-utils/src/trace_collector.ts b/packages/sol-tracing-utils/src/trace_collector.ts index 943e208cf..f5dde8762 100644 --- a/packages/sol-tracing-utils/src/trace_collector.ts +++ b/packages/sol-tracing-utils/src/trace_collector.ts @@ -56,7 +56,7 @@ export class TraceCollector { this._singleFileSubtraceHandler = singleFileSubtraceHandler; } public async writeOutputAsync(): Promise<void> { - const finalCoverage = this._collector.getFinalCoverage(); + const finalCoverage: Coverage = this._collector.getFinalCoverage(); const stringifiedCoverage = JSON.stringify(finalCoverage, null, '\t'); await mkdirpAsync('coverage'); fs.writeFileSync('coverage/coverage.json', stringifiedCoverage); @@ -80,14 +80,14 @@ export class TraceCollector { const bytecodeHex = stripHexPrefix(bytecode); const sourceMap = isContractCreation ? contractData.sourceMap : contractData.sourceMapRuntime; const pcToSourceRange = parseSourceMap(contractData.sourceCodes, sourceMap, bytecodeHex, contractData.sources); - for (let fileIndex = 0; fileIndex < contractData.sources.length; fileIndex++) { + _.map(contractData.sources, (_sourcePath: string, fileIndex: string) => { const singleFileCoverageForTrace = this._singleFileSubtraceHandler( contractData, traceInfo.subtrace, pcToSourceRange, - fileIndex, + _.parseInt(fileIndex), ); this._collector.add(singleFileCoverageForTrace); - } + }); } } diff --git a/packages/sol-tracing-utils/src/trace_info_subprovider.ts b/packages/sol-tracing-utils/src/trace_info_subprovider.ts index 635a68f58..b75fc7bf7 100644 --- a/packages/sol-tracing-utils/src/trace_info_subprovider.ts +++ b/packages/sol-tracing-utils/src/trace_info_subprovider.ts @@ -1,7 +1,8 @@ +import { NodeType } from '@0x/web3-wrapper'; import * as _ from 'lodash'; import { constants } from './constants'; -import { getTracesByContractAddress } from './trace'; +import { getContractAddressToTraces } from './trace'; import { TraceCollectionSubprovider } from './trace_collection_subprovider'; import { TraceInfo, TraceInfoExistingContract, TraceInfoNewContract } from './types'; @@ -12,18 +13,50 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider { protected abstract _handleTraceInfoAsync(traceInfo: TraceInfo): Promise<void>; protected async _recordTxTraceAsync(address: string, data: string | undefined, txHash: string): Promise<void> { await this._web3Wrapper.awaitTransactionMinedAsync(txHash, 0); - const trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, { - disableMemory: true, - disableStack: false, - disableStorage: true, - }); - const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address); - const subcallAddresses = _.keys(tracesByContractAddress); + const nodeType = await this._web3Wrapper.getNodeTypeAsync(); + let trace; + if (nodeType === NodeType.Geth) { + // For very large traces we use a custom tracer that outputs a format compatible with a + // regular trace. We only need the 2nd item on the stack when the instruction is a call. + // By not including other stack values, we drastically limit the amount of data to be collected. + // There are no good docs about how to write those tracers, but you can find some example ones here: + // https://github.com/ethereum/go-ethereum/tree/master/eth/tracers/internal/tracers + const tracer = ` + { + data: [], + step: function(log) { + const op = log.op.toString(); + const opn = 0 | log.op.toNumber(); + const pc = 0 | log.getPC(); + const depth = 0 | log.getDepth(); + const gasCost = 0 | log.getCost(); + const gas = 0 | log.getGas(); + const isCall = opn == 0xf1 || opn == 0xf2 || opn == 0xf4 || opn == 0xf5; + const stack = isCall ? ['0x'+log.stack.peek(1).toString(16), null] : null; + this.data.push({ pc, gasCost, depth, op, stack, gas }); + }, + fault: function() { }, + result: function() { return {structLogs: this.data}; } + } + `; + trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, { tracer, timeout: '600s' }); + } else { + /** + * Ganache doesn't support custom tracers yet. + */ + trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, { + disableMemory: true, + disableStack: false, + disableStorage: true, + }); + } + const contractAddressToTraces = getContractAddressToTraces(trace.structLogs, address); + const subcallAddresses = _.keys(contractAddressToTraces); if (address === constants.NEW_CONTRACT) { for (const subcallAddress of subcallAddresses) { let traceInfo: TraceInfoNewContract | TraceInfoExistingContract; if (subcallAddress === 'NEW_CONTRACT') { - const traceForThatSubcall = tracesByContractAddress[subcallAddress]; + const traceForThatSubcall = contractAddressToTraces[subcallAddress]; traceInfo = { subtrace: traceForThatSubcall, txHash, @@ -32,7 +65,7 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider { }; } else { const runtimeBytecode = await this._web3Wrapper.getContractCodeAsync(subcallAddress); - const traceForThatSubcall = tracesByContractAddress[subcallAddress]; + const traceForThatSubcall = contractAddressToTraces[subcallAddress]; traceInfo = { subtrace: traceForThatSubcall, txHash, @@ -45,7 +78,7 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider { } else { for (const subcallAddress of subcallAddresses) { const runtimeBytecode = await this._web3Wrapper.getContractCodeAsync(subcallAddress); - const traceForThatSubcall = tracesByContractAddress[subcallAddress]; + const traceForThatSubcall = contractAddressToTraces[subcallAddress]; const traceInfo: TraceInfoExistingContract = { subtrace: traceForThatSubcall, txHash, diff --git a/packages/sol-tracing-utils/src/types.ts b/packages/sol-tracing-utils/src/types.ts index 54ade0400..27568ae03 100644 --- a/packages/sol-tracing-utils/src/types.ts +++ b/packages/sol-tracing-utils/src/types.ts @@ -16,7 +16,7 @@ export interface SingleFileSourceRange { end: LineColumn; } -export interface LocationByOffset { +export interface OffsetToLocation { [offset: number]: LineColumn; } @@ -76,13 +76,20 @@ export interface Coverage { }; } +export interface SourceCodes { + [sourceId: number]: string; +} +export interface Sources { + [sourceId: number]: string; +} + export interface ContractData { bytecode: string; sourceMap: string; runtimeBytecode: string; sourceMapRuntime: string; - sourceCodes: string[]; - sources: string[]; + sourceCodes: SourceCodes; + sources: Sources; } // Part of the trace executed within the same context diff --git a/packages/sol-tracing-utils/src/utils.ts b/packages/sol-tracing-utils/src/utils.ts index d8bc65e73..644321f32 100644 --- a/packages/sol-tracing-utils/src/utils.ts +++ b/packages/sol-tracing-utils/src/utils.ts @@ -23,6 +23,12 @@ export const utils = { utils.compareLineColumn(childRange.end, parentRange.end) <= 0 ); }, + isRangeEqual(childRange: SingleFileSourceRange, parentRange: SingleFileSourceRange): boolean { + return ( + utils.compareLineColumn(parentRange.start, childRange.start) === 0 && + utils.compareLineColumn(childRange.end, parentRange.end) === 0 + ); + }, bytecodeToBytecodeRegex(bytecode: string): string { const bytecodeRegex = bytecode // Library linking placeholder: __ConvertLib____________________________ diff --git a/packages/sol-tracing-utils/test/source_maps_test.ts b/packages/sol-tracing-utils/test/source_maps_test.ts index 5820bedd7..330a6a3e1 100644 --- a/packages/sol-tracing-utils/test/source_maps_test.ts +++ b/packages/sol-tracing-utils/test/source_maps_test.ts @@ -4,7 +4,7 @@ import * as _ from 'lodash'; import 'mocha'; import * as path from 'path'; -import { getLocationByOffset, parseSourceMap } from '../src/source_maps'; +import { getOffsetToLocation, parseSourceMap } from '../src/source_maps'; const expect = chai.expect; @@ -15,7 +15,7 @@ const simplestContract = fs.readFileSync(simplestContractFileName).toString(); describe('source maps', () => { describe('#getLocationByOffset', () => { it('correctly computes location by offset', () => { - const locationByOffset = getLocationByOffset(simplestContract); + const offsetToLocation = getOffsetToLocation(simplestContract); const expectedLocationByOffset = { '0': { line: 1, column: 0 }, '1': { line: 1, column: 1 }, @@ -41,7 +41,7 @@ describe('source maps', () => { '21': { line: 2, column: 1 }, '22': { line: 3, column: 0 }, }; - expect(locationByOffset).to.be.deep.equal(expectedLocationByOffset); + expect(offsetToLocation).to.be.deep.equal(expectedLocationByOffset); }); }); describe('#parseSourceMap', () => { diff --git a/packages/sol-tracing-utils/test/trace_test.ts b/packages/sol-tracing-utils/test/trace_test.ts index 7a034362c..c9ed93e63 100644 --- a/packages/sol-tracing-utils/test/trace_test.ts +++ b/packages/sol-tracing-utils/test/trace_test.ts @@ -3,7 +3,7 @@ import { OpCode, StructLog } from 'ethereum-types'; import * as _ from 'lodash'; import 'mocha'; -import { getTracesByContractAddress } from '../src/trace'; +import { getContractAddressToTraces } from '../src/trace'; const expect = chai.expect; @@ -44,7 +44,7 @@ describe('Trace', () => { ]; const fullTrace = _.map(trace, compactStructLog => addDefaultStructLogFields(compactStructLog)); const startAddress = '0x0000000000000000000000000000000000000001'; - const traceByContractAddress = getTracesByContractAddress(fullTrace, startAddress); + const traceByContractAddress = getContractAddressToTraces(fullTrace, startAddress); const expectedTraceByContractAddress = { [startAddress]: [fullTrace[0], fullTrace[2]], [delegateCallAddress]: [fullTrace[1]], diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index 7132d098f..3f2a9fbc1 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.0.16", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.0.15", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "1.0.14", "changes": [ diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index 36b6b1fb0..5fe40ccb4 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.16 - _January 15, 2019_ + + * Dependencies updated + +## v1.0.15 - _January 11, 2019_ + + * Dependencies updated + ## v1.0.14 - _January 9, 2019_ * Dependencies updated diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index a0caea0f4..9c4c0a24f 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sra-spec", - "version": "1.0.14", + "version": "1.0.16", "engines": { "node": ">=6.12" }, @@ -35,11 +35,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0x/json-schemas": "^2.1.5", + "@0x/json-schemas": "^2.1.7", "@loopback/openapi-v3-types": "^0.8.2" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/mocha": "^2.2.42", "@types/node": "^10.5.3", "chai": "^4.0.1", diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index c7763214f..dd4dccf4e 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "2.1.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "2.1.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "2.1.9", "changes": [ diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index 076cce935..16457ee2b 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.11 - _January 15, 2019_ + + * Dependencies updated + +## v2.1.10 - _January 11, 2019_ + + * Dependencies updated + ## v2.1.9 - _January 9, 2019_ * Dependencies updated diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 178e7a99c..d5dc2b052 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0x/subproviders", - "version": "2.1.9", + "version": "2.1.11", "engines": { "node": ">=6.12" }, @@ -29,11 +29,11 @@ } }, "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/assert": "^1.0.23", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "4.24.0", "@types/eth-lightwallet": "^3.0.0", @@ -43,7 +43,7 @@ "bip39": "^2.5.0", "bn.js": "^4.11.8", "eth-lightwallet": "^3.0.1", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "ganache-core": "^2.2.1", @@ -54,7 +54,7 @@ "web3-provider-engine": "14.0.6" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/bip39": "^2.4.0", "@types/bn.js": "^4.11.0", "@types/ethereumjs-tx": "^1.0.0", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index b01ef4b8e..b6e84698d 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0x/testnet-faucets", - "version": "1.0.61", + "version": "1.0.63", "engines": { "node": ">=6.12" }, @@ -18,13 +18,13 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^3.0.0", - "@0x/subproviders": "^2.1.9", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "0x.js": "^3.0.2", + "@0x/subproviders": "^2.1.11", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "body-parser": "^1.17.1", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "express": "^4.15.2", @@ -32,7 +32,7 @@ "rollbar": "^0.6.5" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/body-parser": "^1.16.1", "@types/express": "^4.0.35", "@types/lodash": "4.14.104", diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts index 2dfa3c3af..8f642d4b0 100644 --- a/packages/testnet-faucets/src/ts/handler.ts +++ b/packages/testnet-faucets/src/ts/handler.ts @@ -36,9 +36,9 @@ interface ItemByNetworkId<T> { } enum RequestedAssetType { - ETH = 'ETH', - WETH = 'WETH', - ZRX = 'ZRX', + ETH = 'ETH', // tslint:disable-line:enum-naming + WETH = 'WETH', // tslint:disable-line:enum-naming + ZRX = 'ZRX', // tslint:disable-line:enum-naming } const FIVE_DAYS_IN_MS = 4.32e8; // TODO: make this configurable diff --git a/packages/tslint-config/CHANGELOG.json b/packages/tslint-config/CHANGELOG.json index ccf87e354..fe34592fd 100644 --- a/packages/tslint-config/CHANGELOG.json +++ b/packages/tslint-config/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/tslint-config/CHANGELOG.md b/packages/tslint-config/CHANGELOG.md index 3cebb1e95..37d287c10 100644 --- a/packages/tslint-config/CHANGELOG.md +++ b/packages/tslint-config/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _January 15, 2019_ + + * Dependencies updated + +## v2.0.1 - _January 11, 2019_ + + * Dependencies updated + ## v2.0.0 - _December 13, 2018_ * Improve async-suffix rule to check functions too, not just methods (#1425) diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index 64ec1e967..f90321edb 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@0x/tslint-config", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "scripts": { "build": "tsc -b", "build:ci": "yarn build", + "test": "mocha ./lib/test/*.spec.js", "clean": "shx rm -rf lib", "lint": "tslint --format stylish --project ." }, diff --git a/packages/tslint-config/rules/enumNamingRule.ts b/packages/tslint-config/rules/enumNamingRule.ts new file mode 100644 index 000000000..56499618f --- /dev/null +++ b/packages/tslint-config/rules/enumNamingRule.ts @@ -0,0 +1,60 @@ +import * as Lint from 'tslint'; +import * as ts from 'typescript'; + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING = `Enum member names should be PascalCase`; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithFunction(sourceFile, walk); + } +} + +function walk(ctx: Lint.WalkContext<void>): void { + // Recursively walk the AST starting with root node, `ctx.sourceFile`. + // Call the function `cb` (defined below) for each child. + return ts.forEachChild(ctx.sourceFile, cb); + + function cb(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.EnumMember) { + const keyNode = node.getFirstToken(ctx.sourceFile); + if (keyNode !== undefined) { + const keyText = keyNode.getText(ctx.sourceFile); + if (!isPascalCase(keyText)) { + return ctx.addFailureAtNode(node, Rule.FAILURE_STRING, getFix(keyText, node)); + } + } + } + // Continue recursion into the AST by calling function `cb` for every child of the current node. + return ts.forEachChild(node, cb); + } + + function getFix(text: string, node: ts.Node): Lint.Replacement { + let fix = toPascalCase(text); + // check for `member = value` + if (node.getChildCount(ctx.sourceFile) === 3) { + const value = node.getLastToken(ctx.sourceFile); + if (value !== undefined) { + fix += ` = ${value.getText(ctx.sourceFile)}`; + } + } + return new Lint.Replacement(node.getStart(ctx.sourceFile), node.getWidth(ctx.sourceFile), fix); + } +} + +// Modified from: https://github.com/jonschlinkert/pascalcase/ +function toPascalCase(str: string): string { + let result = str.replace(/([a-z0-9\W])([A-Z])/g, '$1 $2'); + if (result.length === 1) { + return result.toUpperCase(); + } + result = result.replace(/^[\W_\.]+|[\W_\.]+$/g, '').toLowerCase(); + result = result.charAt(0).toUpperCase() + result.slice(1); + return result.replace(/[\W_\.]+(\w|$)/g, (_, ch) => { + return ch.toUpperCase(); + }); +} +function isPascalCase(s: string): boolean { + const regex = /^([A-Z0-9]+[a-z0-9]+)+$/g; + const key = s.split('=')[0].trim(); + return regex.test(key); +} diff --git a/packages/tslint-config/test/enumNamingSpec.spec.ts b/packages/tslint-config/test/enumNamingSpec.spec.ts new file mode 100644 index 000000000..d5b864eba --- /dev/null +++ b/packages/tslint-config/test/enumNamingSpec.spec.ts @@ -0,0 +1,88 @@ +import * as assert from 'assert'; + +import { Rule } from '../rules/enumNamingRule'; + +import { getFixedResult, helper } from './lintrunner'; +const rule = 'enum-naming'; + +describe('enumNamingRule', () => { + it(`should not fail PascalCase`, () => { + const src = `enum test { MemberOne, MemberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should not fail PascalCase keys with uncased values`, () => { + const src = `enum test { MemberOne = 'member_one', MemberTwo = 'member two' }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should not fail PascalCase keys with numbers`, () => { + const src = `enum test { Member1 = 'member_one', MemberTwo = 'member two' }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should fail with camelCase`, () => { + const src = `enum test { memberOne, memberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with snake case`, () => { + const src = `enum test { member_one, member_two }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with all caps`, () => { + const src = `enum test { MEMBERONE, MEMBER_TWO }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with mixed case`, () => { + const src = `enum test { member_one, MemberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 1); + }); + + it(`should fail with the right position`, () => { + const src = `enum test { MemberOne, member_two }`; + const startPosition = src.indexOf('member_two'); + const endPosition = startPosition + 'member_two'.length; + const failure = helper(src, rule).failures[0]; + + assert.equal(failure.getStartPosition().getPosition(), startPosition); + assert.equal(failure.getEndPosition().getPosition(), endPosition); + assert.equal(failure.getFailure(), Rule.FAILURE_STRING); + }); + + it(`should fail with the right message`, () => { + const src = `enum test { memberOne, memberTwo }`; + const failure = helper(src, rule).failures[0]; + + assert.equal(failure.getFailure(), Rule.FAILURE_STRING); + }); +}); +describe('enumNaming fixer', () => { + it('should fix keys', () => { + const src = `enum test { MemberOne, memberTwo, member_three, MEMBER_FOUR, MEMBERFIVE }`; + const expected = `enum test { MemberOne, MemberTwo, MemberThree, MemberFour, Memberfive }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 4); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); + it('should not fix values', () => { + const src = `enum test { MemberOne = 'MemberOne', memberTwo = 'memberTwo', member_three = 'member_three', MEMBER_FOUR = 'MEMBER_FOUR' }`; + const expected = `enum test { MemberOne = 'MemberOne', MemberTwo = 'memberTwo', MemberThree = 'member_three', MemberFour = 'MEMBER_FOUR' }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); + it('should preserve values with equals sign', () => { + const src = `enum Operators { assign = '=', EQUALS = '==', Triple_Equals = '===' }`; + const expected = `enum Operators { Assign = '=', Equals = '==', TripleEquals = '===' }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); +}); diff --git a/packages/tslint-config/test/lintrunner.ts b/packages/tslint-config/test/lintrunner.ts new file mode 100644 index 000000000..fcd1b6844 --- /dev/null +++ b/packages/tslint-config/test/lintrunner.ts @@ -0,0 +1,23 @@ +import * as path from 'path'; +import { Configuration, Linter, Replacement } from 'tslint'; + +export const helper = (src: string, rule: string) => { + const linter = new Linter({ fix: false }); + linter.lint( + '', + src, + Configuration.parseConfigFile({ + rules: { + [rule]: true, + }, + rulesDirectory: path.join(__dirname, '../rules'), + }), + ); + return linter.getResult(); +}; + +export const getFixedResult = (src: string, rule: string) => { + const result = helper(src, rule); + const fixes = [].concat.apply(result.failures.map(x => x.getFix())); + return Replacement.applyFixes(src, fixes); +}; diff --git a/packages/tslint-config/tsconfig.json b/packages/tslint-config/tsconfig.json index 44845cf1f..b9a4dd03e 100644 --- a/packages/tslint-config/tsconfig.json +++ b/packages/tslint-config/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig", "compilerOptions": { "outDir": "lib", - "rootDir": "rules" + "rootDir": "." }, - "include": ["./rules/**/*"] + "include": ["./rules/**/*", "test/**/*"] } diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json index e8de6221e..a5fa6962c 100644 --- a/packages/tslint-config/tslint.json +++ b/packages/tslint-config/tslint.json @@ -25,6 +25,7 @@ "curly": true, "custom-no-magic-numbers": [true, 0, 1, 2, 3, -1], "encoding": true, + "enum-naming": true, "eofline": true, "import-spacing": true, "indent": [true, "spaces", 4], @@ -125,5 +126,5 @@ "check-preblock" ] }, - "rulesDirectory": "lib" + "rulesDirectory": "lib/rules" } diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index dab7e6825..40a46ac84 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "1.5.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "1.5.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.5.0", "changes": [ { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index a1745cf94..ac27d9096 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.5.2 - _January 15, 2019_ + + * Dependencies updated + +## v1.5.1 - _January 11, 2019_ + + * Dependencies updated + ## v1.5.0 - _January 9, 2019_ * Added types for Dutch Auction contract (#1465) diff --git a/packages/types/package.json b/packages/types/package.json index 75c3b7c63..2fea809bc 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0x/types", - "version": "1.5.0", + "version": "1.5.2", "engines": { "node": ">=6.12" }, @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/types/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", "tslint": "5.11.0", @@ -32,7 +32,7 @@ "dependencies": { "@types/node": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.1.4" + "ethereum-types": "^1.1.6" }, "publishConfig": { "access": "public" diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index eb92e773d..cc7ef7fa4 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.0.8", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.6", "changes": [ { diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md index 1663d40af..8f23cce14 100644 --- a/packages/typescript-typings/CHANGELOG.md +++ b/packages/typescript-typings/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.8 - _January 15, 2019_ + + * Dependencies updated + +## v3.0.7 - _January 11, 2019_ + + * Dependencies updated + ## v3.0.6 - _December 13, 2018_ * Dependencies updated diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index c67b660c8..6640760e4 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -1,6 +1,6 @@ { "name": "@0x/typescript-typings", - "version": "3.0.6", + "version": "3.0.8", "engines": { "node": ">=6.12" }, @@ -27,7 +27,7 @@ "@types/bn.js": "^4.11.0", "@types/react": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "popper.js": "1.14.3" }, "devDependencies": { diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 6b4bc3e82..851c106d8 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,12 +1,22 @@ [ { + "timestamp": 1547561734, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { "note": "Make `promisify` resolve when the callback error is undefined.", "pr": 1501 } - ] + ], + "timestamp": 1547225310 }, { "version": "2.1.1", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 15d78e321..ed3f00158 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.1 - _January 15, 2019_ + + * Dependencies updated + +## v3.0.0 - _January 11, 2019_ + + * Make `promisify` resolve when the callback error is undefined. (#1501) + ## v2.1.1 - _January 9, 2019_ * Add `should` prefix to names of properties in EncodingRules and DecodingRules (#1363) diff --git a/packages/utils/package.json b/packages/utils/package.json index 49d6e3013..315f5a08f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/utils", - "version": "2.1.1", + "version": "3.0.1", "engines": { "node": ">=6.12" }, @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/utils/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/detect-node": "2.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -44,14 +44,14 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", "bignumber.js": "~4.1.0", "chalk": "^2.4.1", "detect-node": "2.0.3", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", "isomorphic-fetch": "^2.2.1", diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts index 13cc87e2a..f23324721 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts @@ -51,8 +51,26 @@ export abstract class DataType { return value; } + public decodeAsArray(returndata: string, rules?: DecodingRules): any[] { + const value = this.decode(returndata, rules); + const valuesAsArray = _.isObject(value) ? _.values(value) : [value]; + return valuesAsArray; + } + + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this._dataItem.name) || !isDetailed) { + return this.getSignatureType(); + } + const name = this.getDataItem().name; + const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); + const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; + const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; + const detailedSignature = `${shortName} ${this.getSignatureType()}`; + return detailedSignature; + } + public abstract generateCalldataBlock(value: any, parentBlock?: CalldataBlock): CalldataBlock; public abstract generateValue(calldata: RawCalldata, rules: DecodingRules): any; - public abstract getSignature(): string; + public abstract getSignatureType(): string; public abstract isStatic(): boolean; } diff --git a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts index 00059a4b6..2c6c4b0f6 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts @@ -1,3 +1,4 @@ +import { ObjectMap } from '@0x/types'; import { DataItem } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; @@ -134,31 +135,26 @@ export abstract class AbstractSetDataType extends DataType { const block = new SetCalldataBlock(this.getDataItem().name, this.getSignature(), parentName); // Create blocks for members of set. const memberCalldataBlocks: CalldataBlock[] = []; - const childMap = _.cloneDeep(this._memberIndexByName); - _.forOwn(obj, (value: any, key: string) => { - if (!(key in childMap)) { + _.forEach(this._memberIndexByName, (memberIndex: number, memberName: string) => { + if (!(memberName in obj)) { throw new Error( - `Could not assign tuple to object: unrecognized key '${key}' in object ${this.getDataItem().name}`, + `Could not assign tuple to object: missing key '${memberName}' in object ${JSON.stringify(obj)}`, ); } - const memberBlock = this._members[this._memberIndexByName[key]].generateCalldataBlock(value, block); + const memberValue: any = (obj as ObjectMap<any>)[memberName]; + const memberBlock = this._members[memberIndex].generateCalldataBlock(memberValue, block); memberCalldataBlocks.push(memberBlock); - delete childMap[key]; }); - // Sanity check that all members have been included. - if (Object.keys(childMap).length !== 0) { - throw new Error(`Could not assign tuple to object: missing keys ${Object.keys(childMap)}`); - } // Associate member blocks with Set block. block.setMembers(memberCalldataBlocks); return block; } - protected _computeSignatureOfMembers(): string { + protected _computeSignatureOfMembers(isDetailed?: boolean): string { // Compute signature of members let signature = `(`; _.each(this._members, (member: DataType, i: number) => { - signature += member.getSignature(); + signature += member.getSignature(isDetailed); if (i < this._members.length - 1) { signature += ','; } @@ -179,17 +175,27 @@ export abstract class AbstractSetDataType extends DataType { // Create one member for each component of `dataItem` const members: DataType[] = []; const memberIndexByName: MemberIndexByName = {}; + const memberNames: string[] = []; _.each(dataItem.components, (memberItem: DataItem) => { + // If a component with `name` already exists then + // rename to `name_nameIdx` to avoid naming conflicts. + let memberName = memberItem.name; + let nameIdx = 0; + while (_.includes(memberNames, memberName) || _.isEmpty(memberName)) { + nameIdx++; + memberName = `${memberItem.name}_${nameIdx}`; + } + memberNames.push(memberName); const childDataItem: DataItem = { type: memberItem.type, - name: `${dataItem.name}.${memberItem.name}`, + name: `${dataItem.name}.${memberName}`, }; const components = memberItem.components; if (!_.isUndefined(components)) { childDataItem.components = components; } const child = this.getFactory().create(childDataItem, this); - memberIndexByName[memberItem.name] = members.length; + memberIndexByName[memberName] = members.length; members.push(child); }); return [members, memberIndexByName]; diff --git a/packages/utils/src/abi_encoder/evm_data_type_factory.ts b/packages/utils/src/abi_encoder/evm_data_type_factory.ts index 4cc124e0a..268649148 100644 --- a/packages/utils/src/abi_encoder/evm_data_type_factory.ts +++ b/packages/utils/src/abi_encoder/evm_data_type_factory.ts @@ -2,6 +2,8 @@ import { DataItem, MethodAbi } from 'ethereum-types'; import * as _ from 'lodash'; +import { generateDataItemsFromSignature } from './utils/signature_parser'; + import { DataType } from './abstract_data_types/data_type'; import { DataTypeFactory } from './abstract_data_types/interfaces'; import { AddressDataType } from './evm_data_types/address'; @@ -129,4 +131,35 @@ export class EvmDataTypeFactory implements DataTypeFactory { private constructor() {} } + +/** + * Convenience function for creating a DataType from different inputs. + * @param input A single or set of DataItem or a DataType signature. + * A signature in the form of '<type>' is interpreted as a `DataItem` + * For example, 'string' is interpreted as {type: 'string'} + * A signature in the form '(<type1>, <type2>, ..., <typen>)' is interpreted as `DataItem[]` + * For eaxmple, '(string, uint256)' is interpreted as [{type: 'string'}, {type: 'uint256'}] + * @return DataType corresponding to input. + */ +export function create(input: DataItem | DataItem[] | string): DataType { + // Handle different types of input + const isSignature = typeof input === 'string'; + const isTupleSignature = isSignature && (input as string).startsWith('('); + const shouldParseAsTuple = isTupleSignature || _.isArray(input); + // Create input `dataItem` + let dataItem: DataItem; + if (shouldParseAsTuple) { + const dataItems = isSignature ? generateDataItemsFromSignature(input as string) : (input as DataItem[]); + dataItem = { + name: '', + type: 'tuple', + components: dataItems, + }; + } else { + dataItem = isSignature ? generateDataItemsFromSignature(input as string)[0] : (input as DataItem); + } + // Create data type + const dataType = EvmDataTypeFactory.getInstance().create(dataItem); + return dataType; +} /* tslint:enable no-construct */ diff --git a/packages/utils/src/abi_encoder/evm_data_types/address.ts b/packages/utils/src/abi_encoder/evm_data_types/address.ts index 2e3a206c6..2278830eb 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/address.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/address.ts @@ -39,10 +39,11 @@ export class AddressDataType extends AbstractBlobDataType { const valueBufPadded = calldata.popWord(); const valueBuf = valueBufPadded.slice(AddressDataType._DECODED_ADDRESS_OFFSET_IN_BYTES); const value = ethUtil.bufferToHex(valueBuf); - return value; + const valueLowercase = _.toLower(value); + return valueLowercase; } - public getSignature(): string { + public getSignatureType(): string { return SolidityTypes.Address; } /* tslint:enable prefer-function-over-method */ diff --git a/packages/utils/src/abi_encoder/evm_data_types/array.ts b/packages/utils/src/abi_encoder/evm_data_types/array.ts index 7595cb667..d9607f47e 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/array.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/array.ts @@ -7,7 +7,6 @@ import { constants } from '../utils/constants'; export class ArrayDataType extends AbstractSetDataType { private static readonly _MATCHER = RegExp('^(.+)\\[([0-9]*)\\]$'); - private readonly _arraySignature: string; private readonly _elementType: string; public static matchType(type: string): boolean { @@ -35,25 +34,36 @@ export class ArrayDataType extends AbstractSetDataType { super(dataItem, dataTypeFactory, isArray, arrayLength, arrayElementType); // Set array properties this._elementType = arrayElementType; - this._arraySignature = this._computeSignature(); } - public getSignature(): string { - return this._arraySignature; + public getSignatureType(): string { + return this._computeSignature(false); } - private _computeSignature(): string { + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this.getDataItem().name) || !isDetailed) { + return this.getSignatureType(); + } + const name = this.getDataItem().name; + const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); + const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; + const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; + const detailedSignature = `${shortName} ${this._computeSignature(isDetailed)}`; + return detailedSignature; + } + + private _computeSignature(isDetailed?: boolean): string { // Compute signature for a single array element const elementDataItem: DataItem = { type: this._elementType, - name: 'N/A', + name: '', }; const elementComponents = this.getDataItem().components; if (!_.isUndefined(elementComponents)) { elementDataItem.components = elementComponents; } const elementDataType = this.getFactory().create(elementDataItem); - const elementSignature = elementDataType.getSignature(); + const elementSignature = elementDataType.getSignature(isDetailed); // Construct signature for array of type `element` if (_.isUndefined(this._arrayLength)) { return `${elementSignature}[]`; diff --git a/packages/utils/src/abi_encoder/evm_data_types/bool.ts b/packages/utils/src/abi_encoder/evm_data_types/bool.ts index d713d5a94..7f91f34e6 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts @@ -46,7 +46,7 @@ export class BoolDataType extends AbstractBlobDataType { return value; } - public getSignature(): string { + public getSignatureType(): string { return SolidityTypes.Bool; } /* tslint:enable prefer-function-over-method */ diff --git a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts index 5277efd6c..fa38b63c0 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts @@ -65,7 +65,7 @@ export class DynamicBytesDataType extends AbstractBlobDataType { return value; } - public getSignature(): string { + public getSignatureType(): string { return SolidityTypes.Bytes; } /* tslint:enable prefer-function-over-method */ diff --git a/packages/utils/src/abi_encoder/evm_data_types/int.ts b/packages/utils/src/abi_encoder/evm_data_types/int.ts index f1dcf5ea1..8d98e195b 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/int.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts @@ -47,13 +47,17 @@ export class IntDataType extends AbstractBlobDataType { return encodedValue; } - public decodeValue(calldata: RawCalldata): BigNumber { + public decodeValue(calldata: RawCalldata): BigNumber | number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, this._minValue, this._maxValue); + const numberOfBytesInUint8 = 8; + if (this._width === numberOfBytesInUint8) { + return value.toNumber(); + } return value; } - public getSignature(): string { + public getSignatureType(): string { return `${SolidityTypes.Int}${this._width}`; } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/method.ts b/packages/utils/src/abi_encoder/evm_data_types/method.ts index b1cd1377f..c852a0fdf 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/method.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/method.ts @@ -44,7 +44,20 @@ export class MethodDataType extends AbstractSetDataType { return returnValues; } - public getSignature(): string { + public strictDecodeReturnValue<T>(returndata: string, rules?: DecodingRules): T { + const returnValues = this._returnDataType.decode(returndata, rules); + const returnValuesAsArray: any = _.isObject(returnValues) ? _.values(returnValues) : [returnValues]; + switch (returnValuesAsArray.length) { + case 0: + return undefined as any; + case 1: + return returnValuesAsArray[0]; + default: + return returnValuesAsArray; + } + } + + public getSignatureType(): string { return this._methodSignature; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts index 389e75927..250db7c64 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts @@ -11,7 +11,11 @@ export class PointerDataType extends AbstractPointerDataType { super(dataItem, dataTypeFactory, destDataType, parentDataType); } - public getSignature(): string { - return this._destination.getSignature(); + public getSignatureType(): string { + return this._destination.getSignature(false); + } + + public getSignature(isDetailed?: boolean): string { + return this._destination.getSignature(isDetailed); } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts index 2e371c505..cbf1957d7 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts @@ -36,7 +36,7 @@ export class StaticBytesDataType extends AbstractBlobDataType { this._width = StaticBytesDataType._decodeWidthFromType(dataItem.type); } - public getSignature(): string { + public getSignatureType(): string { // Note that `byte` reduces to `bytes1` return `${SolidityTypes.Bytes}${this._width}`; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/string.ts b/packages/utils/src/abi_encoder/evm_data_types/string.ts index 91a72ad3f..97ac46442 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/string.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/string.ts @@ -52,7 +52,7 @@ export class StringDataType extends AbstractBlobDataType { return value; } - public getSignature(): string { + public getSignatureType(): string { return SolidityTypes.String; } /* tslint:enable prefer-function-over-method */ diff --git a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts index 31593c882..5000c85e8 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts @@ -1,11 +1,10 @@ import { DataItem, SolidityTypes } from 'ethereum-types'; +import * as _ from 'lodash'; import { DataTypeFactory } from '../abstract_data_types/interfaces'; import { AbstractSetDataType } from '../abstract_data_types/types/set'; export class TupleDataType extends AbstractSetDataType { - private readonly _signature: string; - public static matchType(type: string): boolean { return type === SolidityTypes.Tuple; } @@ -15,10 +14,21 @@ export class TupleDataType extends AbstractSetDataType { if (!TupleDataType.matchType(dataItem.type)) { throw new Error(`Tried to instantiate Tuple with bad input: ${dataItem}`); } - this._signature = this._computeSignatureOfMembers(); } - public getSignature(): string { - return this._signature; + public getSignatureType(): string { + return this._computeSignatureOfMembers(false); + } + + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this.getDataItem().name) || !isDetailed) { + return this.getSignatureType(); + } + const name = this.getDataItem().name; + const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); + const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; + const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; + const detailedSignature = `${shortName} ${this._computeSignatureOfMembers(isDetailed)}`; + return detailedSignature; } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/uint.ts b/packages/utils/src/abi_encoder/evm_data_types/uint.ts index 5180f0cf3..8e382e8dc 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts @@ -46,13 +46,17 @@ export class UIntDataType extends AbstractBlobDataType { return encodedValue; } - public decodeValue(calldata: RawCalldata): BigNumber { + public decodeValue(calldata: RawCalldata): BigNumber | number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue); + const numberOfBytesInUint8 = 8; + if (this._width === numberOfBytesInUint8) { + return value.toNumber(); + } return value; } - public getSignature(): string { + public getSignatureType(): string { return `${SolidityTypes.Uint}${this._width}`; } } diff --git a/packages/utils/src/abi_encoder/index.ts b/packages/utils/src/abi_encoder/index.ts index baf844ac6..cfacfe075 100644 --- a/packages/utils/src/abi_encoder/index.ts +++ b/packages/utils/src/abi_encoder/index.ts @@ -11,4 +11,6 @@ export { String, Tuple, UInt, + create, } from './evm_data_type_factory'; +export { DataType } from './abstract_data_types/data_type'; diff --git a/packages/utils/src/abi_encoder/utils/constants.ts b/packages/utils/src/abi_encoder/utils/constants.ts index 36de2dd4f..fc586f295 100644 --- a/packages/utils/src/abi_encoder/utils/constants.ts +++ b/packages/utils/src/abi_encoder/utils/constants.ts @@ -11,7 +11,7 @@ export const constants = { HEX_SELECTOR_BYTE_OFFSET_IN_CALLDATA: 0, // Disable no-object-literal-type-assertion so we can enforce cast /* tslint:disable no-object-literal-type-assertion */ - DEFAULT_DECODING_RULES: { shouldConvertStructsToObjects: false } as DecodingRules, + DEFAULT_DECODING_RULES: { shouldConvertStructsToObjects: true } as DecodingRules, DEFAULT_ENCODING_RULES: { shouldOptimize: true, shouldAnnotate: false } as EncodingRules, /* tslint:enable no-object-literal-type-assertion */ }; diff --git a/packages/utils/src/abi_encoder/utils/signature_parser.ts b/packages/utils/src/abi_encoder/utils/signature_parser.ts new file mode 100644 index 000000000..315784cea --- /dev/null +++ b/packages/utils/src/abi_encoder/utils/signature_parser.ts @@ -0,0 +1,101 @@ +import { DataItem } from 'ethereum-types'; +import * as _ from 'lodash'; + +/** + * Returns an array of DataItem's corresponding to the input signature. + * A signature can be in two forms: '<DataItem.type>' or '(<DataItem1.type>, <DataItem2.type>, ...) + * An example of the first form would be 'address' or 'uint256' + * An example of the second form would be '(address, uint256)' + * Signatures can also include a name field, for example: 'foo address' or '(foo address, bar uint256)' + * @param signature of input DataItems + * @return DataItems derived from input signature + */ +export function generateDataItemsFromSignature(signature: string): DataItem[] { + let trimmedSignature = signature; + if (signature.startsWith('(')) { + if (!signature.endsWith(')')) { + throw new Error(`Failed to generate data item. Must end with ')'`); + } + trimmedSignature = signature.substr(1, signature.length - 2); + } + trimmedSignature += ','; + let isCurrTokenArray = false; + let currTokenArrayModifier = ''; + let isParsingArrayModifier = false; + let currToken = ''; + let parenCount = 0; + let currTokenName = ''; + const dataItems: DataItem[] = []; + for (const char of trimmedSignature) { + // Tokenize the type string while keeping track of parentheses. + switch (char) { + case '(': + parenCount += 1; + currToken += char; + break; + case ')': + parenCount -= 1; + currToken += char; + break; + case '[': + if (parenCount === 0) { + isParsingArrayModifier = true; + isCurrTokenArray = true; + currTokenArrayModifier += '['; + } else { + currToken += char; + } + break; + case ']': + if (parenCount === 0) { + isParsingArrayModifier = false; + currTokenArrayModifier += ']'; + } else { + currToken += char; + } + break; + case ' ': + if (parenCount === 0) { + currTokenName = currToken; + currToken = ''; + } else { + currToken += char; + } + break; + case ',': + if (parenCount === 0) { + // Generate new DataItem from token + const components = currToken.startsWith('(') ? generateDataItemsFromSignature(currToken) : []; + const isTuple = !_.isEmpty(components); + const dataItem: DataItem = { name: currTokenName, type: '' }; + if (isTuple) { + dataItem.type = 'tuple'; + dataItem.components = components; + } else { + dataItem.type = currToken; + } + if (isCurrTokenArray) { + dataItem.type += currTokenArrayModifier; + } + dataItems.push(dataItem); + // reset token state + currTokenName = ''; + currToken = ''; + isCurrTokenArray = false; + currTokenArrayModifier = ''; + break; + } else { + currToken += char; + break; + } + default: + if (isParsingArrayModifier) { + currTokenArrayModifier += char; + } else { + currToken += char; + } + break; + } + } + return dataItems; +} diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts index 55d582d10..54d536a7e 100644 --- a/packages/utils/test/abi_encoder/evm_data_types_test.ts +++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts @@ -26,6 +26,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic size; Static elements', async () => { // Create DataType object @@ -41,6 +45,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Fixed size; Dynamic elements', async () => { // Create DataType object @@ -56,6 +64,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic size; Dynamic elements', async () => { // Create DataType object @@ -71,6 +83,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic Size; Multidimensional; Dynamic Elements', async () => { // Create DataType object @@ -89,6 +105,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic Size; Multidimensional; Static Elements', async () => { // Create DataType object @@ -107,6 +127,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static Size; Multidimensional; Static Elements', async () => { // Create DataType object @@ -124,6 +148,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static Size; Multidimensional; Dynamic Elements', async () => { // Create DataType object @@ -141,6 +169,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static size; Too Few Elements', async () => { // Create DataType object @@ -197,6 +229,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args, encodingRules); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic elements only', async () => { // Create DataType object @@ -217,6 +253,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Static Array', async () => { // Create DataType object @@ -237,6 +277,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Dynamic Array', async () => { // Create DataType object @@ -257,6 +301,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Static Multidimensional Array', async () => { // Create DataType object @@ -279,6 +327,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Dynamic Multidimensional Array', async () => { // Create DataType object @@ -301,6 +353,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static and dynamic elements mixed', async () => { // Create DataType object @@ -331,6 +387,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Missing Key', async () => { // Create DataType object @@ -345,22 +405,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Encode Args and validate result expect(() => { dataType.encode(args, encodingRules); - }).to.throw('Could not assign tuple to object: missing keys field_2'); - }); - it('Bad Key', async () => { - // Create DataType object - const testDataItem = { - name: 'Tuple', - type: 'tuple', - components: [{ name: 'field_1', type: 'int32' }, { name: 'field_2', type: 'bool' }], - }; - const dataType = new AbiEncoder.Tuple(testDataItem); - // Construct args to be encoded - const args = { unknown_field: new BigNumber(-5) }; - // Encode Args and validate result - expect(() => { - dataType.encode(args, encodingRules); - }).to.throw("Could not assign tuple to object: unrecognized key 'unknown_field' in object Tuple"); + }).to.throw('Could not assign tuple to object: missing key \'field_2\' in object {"field_1":"-5"}'); }); }); @@ -378,6 +423,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Invalid Address - input is not valid hex', async () => { // Create DataType object @@ -417,6 +466,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('False', async () => { // Create DataType object @@ -431,6 +484,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); }); @@ -455,6 +512,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Negative Base Case', async () => { // Create DataType object @@ -469,6 +530,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Positive Value', async () => { // Create DataType object @@ -483,6 +548,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Negative Value', async () => { // Create DataType object @@ -497,6 +566,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Value too large', async () => { // Create DataType object @@ -533,6 +606,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Negative Base Case', async () => { // Create DataType object @@ -547,6 +624,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Positive Value', async () => { // Create DataType object @@ -561,6 +642,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Negative Value', async () => { // Create DataType object @@ -575,6 +660,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Value too large', async () => { // Create DataType object @@ -621,6 +710,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Positive Value', async () => { // Create DataType object @@ -635,6 +728,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Zero Value', async () => { // Create DataType object @@ -649,6 +746,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Value too large', async () => { // Create DataType object @@ -685,6 +786,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Positive Value', async () => { // Create DataType object @@ -699,6 +804,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Zero Value', async () => { // Create DataType object @@ -713,6 +822,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Value too large', async () => { // Create DataType object @@ -752,6 +865,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Single Byte (bytes1)', async () => { // Create DataType object @@ -766,6 +883,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('4 Bytes (bytes4)', async () => { // Create DataType object @@ -780,6 +901,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('4 Bytes (bytes4); Encoder must pad input', async () => { // Create DataType object @@ -796,6 +921,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); const paddedArgs = '0x1a180000'; expect(decodedArgs).to.be.deep.equal(paddedArgs); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('32 Bytes (bytes32)', async () => { // Create DataType object @@ -810,6 +939,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('32 Bytes (bytes32); Encoder must pad input', async () => { // Create DataType object @@ -826,6 +959,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); const paddedArgs = '0x1a18bf6100000000000000000000000000000000000000000000000000000000'; expect(decodedArgs).to.be.deep.equal(paddedArgs); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Should throw when pass in too many bytes (bytes4)', async () => { // Create DataType object @@ -893,6 +1030,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Spans multiple EVM words', async () => { // Create DataType object @@ -910,6 +1051,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Input as Buffer', async () => { // Create DataType object @@ -927,6 +1072,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Should throw when pass in bad hex (no 0x prefix)', async () => { // Create DataType object @@ -968,6 +1117,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Spans multiple EVM words', async () => { // Create DataType object @@ -985,6 +1138,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('String that begins with 0x prefix', async () => { // Create DataType object @@ -1002,6 +1159,10 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Decode Encoded Args and validate result const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); }); }); diff --git a/packages/utils/test/abi_encoder/methods_test.ts b/packages/utils/test/abi_encoder/methods_test.ts index a0525967e..d8045fece 100644 --- a/packages/utils/test/abi_encoder/methods_test.ts +++ b/packages/utils/test/abi_encoder/methods_test.ts @@ -21,7 +21,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x09f2b0c30000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000015600000000000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Array of Static Tuples (Array has defined length)', async () => { @@ -40,7 +41,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x9eb20969000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Array of Static Tuples (Array has dynamic length)', async () => { @@ -59,7 +61,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x63275d6e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Array of Dynamic Tuples (Array has defined length)', async () => { @@ -78,7 +81,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0xdeedb00f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000013400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000138000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023136000000000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Array of Dynamic Tuples (Array has dynamic length)', async () => { @@ -97,7 +101,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x60c847fb000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000013400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000138000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023136000000000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Multidimensional Arrays / Static Members', async () => { @@ -108,19 +113,16 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { const args = []; const argsLength = 8; for (let i = 0; i < argsLength; ++i) { - args.push([ - [[new BigNumber(++value), new BigNumber(++value)], [new BigNumber(++value), new BigNumber(++value)]], - [[new BigNumber(++value), new BigNumber(++value)], [new BigNumber(++value), new BigNumber(++value)]], - ]); + args.push([[[++value, ++value], [++value, ++value]], [[++value, ++value], [++value, ++value]]]); } const calldata = method.encode(args, encodingRules); // Validate calldata const expectedCalldata = '0xc2f47d6f00000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000d400000000000000000000000000000000000000000000000000000000000000e600000000000000000000000000000000000000000000000000000000000000039000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003d000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000003f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001500000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001d000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000001f000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000230000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000027000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000035000000000000000000000000000000000000000000000000000000000000003600000000000000000000000000000000000000000000000000000000000000370000000000000000000000000000000000000000000000000000000000000038'; expect(calldata).to.be.equal(expectedCalldata); - expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Multidimensional Arrays / Dynamic Members', async () => { @@ -148,7 +150,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x81534ebd0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000137000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000139000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000231320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002313300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000231350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000231370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023139000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000232300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023231000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000232320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000232350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002323600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000232370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002323800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002333100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023332000000000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Fixed Length Array / Dynamic Members', async () => { @@ -161,7 +164,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x243a6e6e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Fixed Length Array / Dynamic Members', async () => { @@ -174,7 +178,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x243a6e6e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Unfixed Length Array / Dynamic Members ABI', async () => { @@ -187,33 +192,40 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Unfixed Length Array / Static Members ABI', async () => { // Generate calldata const method = new AbiEncoder.Method(AbiSamples.dynamicArrayStaticMembersAbi); - const args = [[new BigNumber(127), new BigNumber(14), new BigNumber(54)]]; + // tslint:disable custom-no-magic-numbers + const args = [[127, 14, 54]]; + // tslint:enable custom-no-magic-numbers const calldata = method.encode(args, encodingRules); // Validate calldata const expectedCalldata = '0x4fc8a83300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000036'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Fixed Length Array / Static Members ABI', async () => { // Generate calldata const method = new AbiEncoder.Method(AbiSamples.staticArrayAbi); - const args = [[new BigNumber(127), new BigNumber(14), new BigNumber(54)]]; + // tslint:disable custom-no-magic-numbers + const args = [[127, 14, 54]]; + // tslint:enable custom-no-magic-numbers const calldata = method.encode(args, encodingRules); // Validate calldata const expectedCalldata = '0xf68ade72000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000036'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Array ABI', async () => { @@ -226,7 +238,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000373697800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005736576656e000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Static Tuple', async () => { @@ -240,7 +253,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0xa9125e150000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Dynamic Tuple (Array input)', async () => { @@ -254,7 +268,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x5b998f3500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Dynamic Tuple (Object input)', async () => { @@ -268,7 +283,8 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x5b998f3500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Large, Flat ABI', async () => { @@ -291,13 +307,16 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { '0x312d4d42000000000000000000000000000000000000000000000000000000000f4d9feefffffffffffffffffffffffffffffffffffffffffffffffffffffffff0b26012000000000000000000000000000000000000000000000000000000000006a0444300000000000000000000000000000000000000000000000000000000000000000102030405060708091112131415161718192021222324252627282930313200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000180000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f4980000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000003800010203040506070809111213141516171819202122232425262728293031320809111213141516171819202122232425262728293031320000000000000000000000000000000000000000000000000000000000000000000000000000002c4c6974746c65207065746572207069706572207069706564206120706970696e672070657070657220706f740000000000000000000000000000000000000000'; expect(calldata).to.be.equal(expectedCalldata); // Validate decoding - const decodedValue = method.decode(calldata); + const decodingRules = { shouldConvertStructsToObjects: false }; + const decodedValue = method.decode(calldata, decodingRules); expect(decodedValue).to.be.deep.equal(args); }); it('Large, Nested ABI', async () => { // Construct Calldata const method = new AbiEncoder.Method(AbiSamples.largeNestedAbi); - const someStaticArray = [new BigNumber(127), new BigNumber(14), new BigNumber(54)]; + // tslint:disable custom-no-magic-numbers + const someStaticArray = [127, 14, 54]; + // tslint:enable custom-no-magic-numbers const someStaticArrayWithDynamicMembers = [ 'the little piping piper piped a piping pipper papper', 'the kid knows how to write poems, what can I say -- I guess theres a lot I could say to try to fill this line with a lot of text.', diff --git a/packages/utils/test/abi_encoder/optimizer_test.ts b/packages/utils/test/abi_encoder/optimizer_test.ts index ee0654ec3..c2881f14c 100644 --- a/packages/utils/test/abi_encoder/optimizer_test.ts +++ b/packages/utils/test/abi_encoder/optimizer_test.ts @@ -23,7 +23,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x7221063300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000096'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Dynamic Arrays with Dynamic Elements', async () => { @@ -38,7 +38,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0xbb4f12e300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Static Arrays with Static Elements (should not optimize)', async () => { @@ -55,7 +55,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { const unoptimizedCalldata = method.encode(args); expect(optimizedCalldata).to.be.equal(unoptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Static Arrays with Dynamic Elements', async () => { @@ -70,7 +70,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x9fe31f8e0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Array Elements (should optimize)', async () => { @@ -84,7 +84,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuple Fields', async () => { @@ -98,7 +98,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x16780a5e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Strings', async () => { @@ -115,7 +115,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x07370bfa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Bytes', async () => { @@ -133,7 +133,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x6045e42900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002801020304050607080910111213141516171819202122232425262728293031323334353637383940000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuples', async () => { @@ -148,7 +148,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x564f826d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000006792a000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Fields Across Two Tuples', async () => { @@ -164,7 +164,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x564f826d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Arrays, Nested in Separate Tuples', async () => { @@ -180,7 +180,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x18970a9e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000c80000000000000000000000000000000000000000000000000000000000000035657874726120617267756d656e7420746f2070726576656e742065786163746c79206d61746368696e6720746865207475706c65730000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuples, Nested in Separate Tuples', async () => { @@ -196,7 +196,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x0b4d2e6a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c6421000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035657874726120617267756d656e7420746f2070726576656e742065786163746c79206d61746368696e6720746865207475706c65730000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Two-Dimensional Arrays', async () => { @@ -211,7 +211,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x0d28c4f9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000003466f6f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003426172000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035a61610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000003466f6f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003426172000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035a61610000000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Array, Nested within Separate Two-Dimensional Arrays', async () => { @@ -226,14 +226,21 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x0d28c4f900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003466f6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034261720000000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Array Elements Duplicated as Tuple Fields', async () => { // Generate calldata const method = new AbiEncoder.Method(OptimizedAbis.arrayElementsDuplicatedAsTupleFields); - const array = [new BigNumber(100), new BigNumber(150), new BigNumber(200), new BigNumber(225)]; - const tuple = [[array[0]], [array[1]], [array[2]], [array[3]]]; + // tslint:disable custom-no-magic-numbers + const array = [100, 150, 200, 225]; + // tslint:enable custom-no-magic-numbers + const tuple = [ + [new BigNumber(array[0])], + [new BigNumber(array[1])], + [new BigNumber(array[2])], + [new BigNumber(array[3])], + ]; const args = [array, tuple]; // Validata calldata const optimizedCalldata = method.encode(args, encodingRules); @@ -241,7 +248,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0x5b5c78fd0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000e1'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); it('Array Elements Duplicated as Separate Parameter', async () => { @@ -256,7 +263,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { '0xe0e0d34900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000'; expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding - const decodedArgs = method.decode(optimizedCalldata); + const decodedArgs = method.decode(optimizedCalldata, { shouldConvertStructsToObjects: false }); expect(decodedArgs).to.be.deep.equal(args); }); }); diff --git a/packages/utils/test/abi_encoder/return_values_test.ts b/packages/utils/test/abi_encoder/return_values_test.ts index 104c7f5db..308d11ee5 100644 --- a/packages/utils/test/abi_encoder/return_values_test.ts +++ b/packages/utils/test/abi_encoder/return_values_test.ts @@ -15,7 +15,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { // Decode return value const method = new AbiEncoder.Method(ReturnValueAbis.noReturnValues); const returnValue = '0x'; - const decodedReturnValue = method.decodeReturnValues(returnValue); + const decodedReturnValue = method.decodeReturnValues(returnValue, { shouldConvertStructsToObjects: false }); const expectedDecodedReturnValue: any[] = []; expect(decodedReturnValue).to.be.deep.equal(expectedDecodedReturnValue); }); @@ -24,7 +24,9 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); const returnValue = ['0x01020304']; const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); // Validate decoded return value expect(decodedReturnValue).to.be.deep.equal(returnValue); }); @@ -33,7 +35,9 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); const returnValue = ['0x01020304', '0x05060708']; const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); // Validate decoded return value expect(decodedReturnValue).to.be.deep.equal(returnValue); }); @@ -42,7 +46,9 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); const returnValue = ['0x01020304']; const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); // Validate decoded return value expect(decodedReturnValue).to.be.deep.equal(returnValue); }); @@ -51,7 +57,9 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { const method = new AbiEncoder.Method(ReturnValueAbis.multipleDynamicReturnValues); const returnValue = ['0x01020304', '0x05060708']; const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); // Validate decoded return value expect(decodedReturnValue).to.be.deep.equal(returnValue); }); @@ -60,7 +68,9 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => { const method = new AbiEncoder.Method(ReturnValueAbis.mixedStaticAndDynamicReturnValues); const returnValue = ['0x01020304', '0x05060708']; const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); // Validate decoded return value expect(decodedReturnValue).to.be.deep.equal(returnValue); }); diff --git a/packages/utils/test/abi_encoder/signature_tests.ts b/packages/utils/test/abi_encoder/signature_tests.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/utils/test/abi_encoder/signature_tests.ts diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 648544761..b9d5a37b1 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1547561734, + "version": "3.2.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1547225310, + "version": "3.2.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1547040760, "version": "3.2.2", "changes": [ diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 4242fe0cc..5850c5474 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.2.4 - _January 15, 2019_ + + * Dependencies updated + +## v3.2.3 - _January 11, 2019_ + + * Dependencies updated + ## v3.2.2 - _January 9, 2019_ * Dependencies updated diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index b67472a8a..ce9c41ae7 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0x/web3-wrapper", - "version": "3.2.2", + "version": "3.2.4", "engines": { "node": ">=6.12" }, @@ -36,7 +36,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-wrapper/README.md", "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.2", "@types/ganache-core": "^2.1.0", "@types/lodash": "4.14.104", "chai": "^4.0.1", @@ -54,11 +54,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/json-schemas": "^2.1.5", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "ethereum-types": "^1.1.4", + "@0x/assert": "^1.0.23", + "@0x/json-schemas": "^2.1.7", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", "lodash": "^4.17.5" diff --git a/packages/website/package.json b/packages/website/package.json index af43fabf9..0d2773a2c 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0x/website", - "version": "0.0.64", + "version": "0.0.66", "engines": { "node": ">=6.12" }, @@ -20,18 +20,18 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "@0x/asset-buyer": "^3.0.5", - "@0x/contract-addresses": "^2.1.0", - "@0x/contract-wrappers": "^4.2.0", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/react-docs": "^1.0.23", - "@0x/react-shared": "^1.1.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/asset-buyer": "^4.0.1", + "@0x/contract-addresses": "^2.2.0", + "@0x/contract-wrappers": "^5.0.0", + "@0x/json-schemas": "^2.1.7", + "@0x/order-utils": "^3.1.2", + "@0x/react-docs": "^1.0.25", + "@0x/react-shared": "^1.1.2", + "@0x/subproviders": "^2.1.11", + "@0x/types": "^1.5.2", + "@0x/typescript-typings": "^3.0.8", + "@0x/utils": "^3.0.1", + "@0x/web3-wrapper": "^3.2.4", "@reach/dialog": "^0.1.2", "@types/react-lazyload": "^2.3.1", "@types/react-loadable": "^5.4.2", @@ -42,7 +42,7 @@ "blockies": "^0.0.2", "bowser": "^1.9.3", "deep-equal": "^1.0.1", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "find-versions": "^2.0.0", "jsonschema": "^1.2.0", @@ -54,18 +54,20 @@ "polished": "^1.9.2", "query-string": "^6.0.0", "rc-slider": "^8.6.3", - "react": "^16.4.2", + "react": "^16.5.2", "react-copy-to-clipboard": "^5.0.0", "react-document-title": "^2.0.3", - "react-dom": "^16.4.2", + "react-dom": "^16.5.2", "react-flickity-component": "^3.1.0", "react-headroom": "2.2.2", "react-helmet": "^5.2.0", "react-lazyload": "^2.3.0", "react-loadable": "^5.5.0", + "react-markdown": "^4.0.6", "react-popper": "^1.0.0-beta.6", "react-redux": "^5.0.3", "react-responsive": "^6.0.1", + "react-router-dom": "^4.3.1", "react-scroll": "0xproject/react-scroll#pr-330-and-replace-state", "react-scrollable-anchor": "^0.6.1", "react-syntax-highlighter": "^10.1.1", diff --git a/packages/website/public/css/basscss.min.css b/packages/website/public/css/basscss.min.css new file mode 100644 index 000000000..cb6f13198 --- /dev/null +++ b/packages/website/public/css/basscss.min.css @@ -0,0 +1 @@ +/*! Basscss | http://basscss.com | MIT License */.h1{font-size:2rem}.h2{font-size:1.5rem}.h3{font-size:1.25rem}.h4{font-size:1rem}.h5{font-size:.875rem}.h6{font-size:.75rem}.font-family-inherit{font-family:inherit}.font-size-inherit{font-size:inherit}.text-decoration-none{text-decoration:none}.bold{font-weight:700}.regular{font-weight:400}.italic{font-style:italic}.caps{text-transform:uppercase;letter-spacing:.2em}.left-align{text-align:left}.center{text-align:center}.right-align{text-align:right}.justify{text-align:justify}.nowrap{white-space:nowrap}.break-word{word-wrap:break-word}.line-height-1{line-height:1}.line-height-2{line-height:1.125}.line-height-3{line-height:1.25}.line-height-4{line-height:1.5}.list-style-none{list-style:none}.underline{text-decoration:underline}.truncate{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.list-reset{list-style:none;padding-left:0}.inline{display:inline}.block{display:block}.inline-block{display:inline-block}.table{display:table}.table-cell{display:table-cell}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-auto{overflow:auto}.clearfix:after,.clearfix:before{content:" ";display:table}.clearfix:after{clear:both}.left{float:left}.right{float:right}.fit{max-width:100%}.max-width-1{max-width:24rem}.max-width-2{max-width:32rem}.max-width-3{max-width:48rem}.max-width-4{max-width:64rem}.border-box{box-sizing:border-box}.align-baseline{vertical-align:baseline}.align-top{vertical-align:top}.align-middle{vertical-align:middle}.align-bottom{vertical-align:bottom}.m0{margin:0}.mt0{margin-top:0}.mr0{margin-right:0}.mb0{margin-bottom:0}.ml0,.mx0{margin-left:0}.mx0{margin-right:0}.my0{margin-top:0;margin-bottom:0}.m1{margin:.5rem}.mt1{margin-top:.5rem}.mr1{margin-right:.5rem}.mb1{margin-bottom:.5rem}.ml1,.mx1{margin-left:.5rem}.mx1{margin-right:.5rem}.my1{margin-top:.5rem;margin-bottom:.5rem}.m2{margin:1rem}.mt2{margin-top:1rem}.mr2{margin-right:1rem}.mb2{margin-bottom:1rem}.ml2,.mx2{margin-left:1rem}.mx2{margin-right:1rem}.my2{margin-top:1rem;margin-bottom:1rem}.m3{margin:2rem}.mt3{margin-top:2rem}.mr3{margin-right:2rem}.mb3{margin-bottom:2rem}.ml3,.mx3{margin-left:2rem}.mx3{margin-right:2rem}.my3{margin-top:2rem;margin-bottom:2rem}.m4{margin:4rem}.mt4{margin-top:4rem}.mr4{margin-right:4rem}.mb4{margin-bottom:4rem}.ml4,.mx4{margin-left:4rem}.mx4{margin-right:4rem}.my4{margin-top:4rem;margin-bottom:4rem}.mxn1{margin-left:-.5rem;margin-right:-.5rem}.mxn2{margin-left:-1rem;margin-right:-1rem}.mxn3{margin-left:-2rem;margin-right:-2rem}.mxn4{margin-left:-4rem;margin-right:-4rem}.ml-auto{margin-left:auto}.mr-auto,.mx-auto{margin-right:auto}.mx-auto{margin-left:auto}.p0{padding:0}.pt0{padding-top:0}.pr0{padding-right:0}.pb0{padding-bottom:0}.pl0,.px0{padding-left:0}.px0{padding-right:0}.py0{padding-top:0;padding-bottom:0}.p1{padding:.5rem}.pt1{padding-top:.5rem}.pr1{padding-right:.5rem}.pb1{padding-bottom:.5rem}.pl1{padding-left:.5rem}.py1{padding-top:.5rem;padding-bottom:.5rem}.px1{padding-left:.5rem;padding-right:.5rem}.p2{padding:1rem}.pt2{padding-top:1rem}.pr2{padding-right:1rem}.pb2{padding-bottom:1rem}.pl2{padding-left:1rem}.py2{padding-top:1rem;padding-bottom:1rem}.px2{padding-left:1rem;padding-right:1rem}.p3{padding:2rem}.pt3{padding-top:2rem}.pr3{padding-right:2rem}.pb3{padding-bottom:2rem}.pl3{padding-left:2rem}.py3{padding-top:2rem;padding-bottom:2rem}.px3{padding-left:2rem;padding-right:2rem}.p4{padding:4rem}.pt4{padding-top:4rem}.pr4{padding-right:4rem}.pb4{padding-bottom:4rem}.pl4{padding-left:4rem}.py4{padding-top:4rem;padding-bottom:4rem}.px4{padding-left:4rem;padding-right:4rem}.col{float:left}.col,.col-right{box-sizing:border-box}.col-right{float:right}.col-1{width:8.33333%}.col-2{width:16.66667%}.col-3{width:25%}.col-4{width:33.33333%}.col-5{width:41.66667%}.col-6{width:50%}.col-7{width:58.33333%}.col-8{width:66.66667%}.col-9{width:75%}.col-10{width:83.33333%}.col-11{width:91.66667%}.col-12{width:100%}@media (min-width:40em){.sm-col{float:left;box-sizing:border-box}.sm-col-right{float:right;box-sizing:border-box}.sm-col-1{width:8.33333%}.sm-col-2{width:16.66667%}.sm-col-3{width:25%}.sm-col-4{width:33.33333%}.sm-col-5{width:41.66667%}.sm-col-6{width:50%}.sm-col-7{width:58.33333%}.sm-col-8{width:66.66667%}.sm-col-9{width:75%}.sm-col-10{width:83.33333%}.sm-col-11{width:91.66667%}.sm-col-12{width:100%}}@media (min-width:52em){.md-col{float:left;box-sizing:border-box}.md-col-right{float:right;box-sizing:border-box}.md-col-1{width:8.33333%}.md-col-2{width:16.66667%}.md-col-3{width:25%}.md-col-4{width:33.33333%}.md-col-5{width:41.66667%}.md-col-6{width:50%}.md-col-7{width:58.33333%}.md-col-8{width:66.66667%}.md-col-9{width:75%}.md-col-10{width:83.33333%}.md-col-11{width:91.66667%}.md-col-12{width:100%}}@media (min-width:64em){.lg-col{float:left;box-sizing:border-box}.lg-col-right{float:right;box-sizing:border-box}.lg-col-1{width:8.33333%}.lg-col-2{width:16.66667%}.lg-col-3{width:25%}.lg-col-4{width:33.33333%}.lg-col-5{width:41.66667%}.lg-col-6{width:50%}.lg-col-7{width:58.33333%}.lg-col-8{width:66.66667%}.lg-col-9{width:75%}.lg-col-10{width:83.33333%}.lg-col-11{width:91.66667%}.lg-col-12{width:100%}}.flex{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}@media (min-width:40em){.sm-flex{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}}@media (min-width:52em){.md-flex{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}}@media (min-width:64em){.lg-flex{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}}.flex-column{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.flex-wrap{-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.items-start{-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;-ms-grid-row-align:flex-start;align-items:flex-start}.items-end{-webkit-box-align:end;-webkit-align-items:flex-end;-ms-flex-align:end;-ms-grid-row-align:flex-end;align-items:flex-end}.items-center{-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.items-baseline{-webkit-box-align:baseline;-webkit-align-items:baseline;-ms-flex-align:baseline;-ms-grid-row-align:baseline;align-items:baseline}.items-stretch{-webkit-box-align:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;-ms-grid-row-align:stretch;align-items:stretch}.self-start{-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start}.self-end{-webkit-align-self:flex-end;-ms-flex-item-align:end;align-self:flex-end}.self-center{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.self-baseline{-webkit-align-self:baseline;-ms-flex-item-align:baseline;align-self:baseline}.self-stretch{-webkit-align-self:stretch;-ms-flex-item-align:stretch;align-self:stretch}.justify-start{-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start}.justify-end{-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end}.justify-center{-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.justify-between{-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}.justify-around{-webkit-justify-content:space-around;-ms-flex-pack:distribute;justify-content:space-around}.content-start{-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}.content-end{-webkit-align-content:flex-end;-ms-flex-line-pack:end;align-content:flex-end}.content-center{-webkit-align-content:center;-ms-flex-line-pack:center;align-content:center}.content-between{-webkit-align-content:space-between;-ms-flex-line-pack:justify;align-content:space-between}.content-around{-webkit-align-content:space-around;-ms-flex-line-pack:distribute;align-content:space-around}.content-stretch{-webkit-align-content:stretch;-ms-flex-line-pack:stretch;align-content:stretch}.flex-auto{-webkit-box-flex:1;-webkit-flex:1 1 auto;-ms-flex:1 1 auto;flex:1 1 auto;min-width:0;min-height:0}.flex-none{-webkit-box-flex:0;-webkit-flex:none;-ms-flex:none;flex:none}.order-0{-webkit-box-ordinal-group:1;-webkit-order:0;-ms-flex-order:0;order:0}.order-1{-webkit-box-ordinal-group:2;-webkit-order:1;-ms-flex-order:1;order:1}.order-2{-webkit-box-ordinal-group:3;-webkit-order:2;-ms-flex-order:2;order:2}.order-3{-webkit-box-ordinal-group:4;-webkit-order:3;-ms-flex-order:3;order:3}.order-last{-webkit-box-ordinal-group:100000;-webkit-order:99999;-ms-flex-order:99999;order:99999}.relative{position:relative}.absolute{position:absolute}.fixed{position:fixed}.top-0{top:0}.right-0{right:0}.bottom-0{bottom:0}.left-0{left:0}.z1{z-index:1}.z2{z-index:2}.z3{z-index:3}.z4{z-index:4}.border{border-style:solid;border-width:1px}.border-top{border-top-style:solid;border-top-width:1px}.border-right{border-right-style:solid;border-right-width:1px}.border-bottom{border-bottom-style:solid;border-bottom-width:1px}.border-left{border-left-style:solid;border-left-width:1px}.border-none{border:0}.rounded{border-radius:3px}.circle{border-radius:50%}.rounded-top{border-radius:3px 3px 0 0}.rounded-right{border-radius:0 3px 3px 0}.rounded-bottom{border-radius:0 0 3px 3px}.rounded-left{border-radius:3px 0 0 3px}.not-rounded{border-radius:0}.hide{position:absolute!important;height:1px;width:1px;overflow:hidden;clip:rect(1px,1px,1px,1px)}@media (max-width:40em){.xs-hide{display:none!important}}@media (min-width:40em) and (max-width:52em){.sm-hide{display:none!important}}@media (min-width:52em) and (max-width:64em){.md-hide{display:none!important}}@media (min-width:64em){.lg-hide{display:none!important}}.display-none{display:none!important}
\ No newline at end of file diff --git a/packages/website/public/index.html b/packages/website/public/index.html index 26ebcdec8..738b675e7 100644 --- a/packages/website/public/index.html +++ b/packages/website/public/index.html @@ -18,6 +18,7 @@ <link rel="stylesheet" href="/css/roboto.css" /> <link rel="stylesheet" href="/css/roboto_mono.css" /> <link rel="stylesheet" href="/css/formular.css" /> + <link rel="stylesheet" href="/css/basscss.min.css" /> <link rel="stylesheet" href="/css/basscss_responsive_custom.css" /> <link rel="stylesheet" href="/css/basscss_responsive_padding.css" /> <link rel="stylesheet" href="/css/basscss_responsive_margin.css" /> diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index e15a2dd94..527353aa0 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -20,8 +20,8 @@ import { utils } from 'ts/utils/utils'; const VALID_ETHEREUM_DERIVATION_PATH_PREFIX = `44'/60'`; enum LedgerSteps { - CONNECT, - SELECT_ADDRESS, + Connect, + SelectAddress, } interface LedgerConfigDialogProps { @@ -52,7 +52,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, const derivationPathIfExists = props.blockchain.getLedgerDerivationPathIfExists(); this.state = { connectionErrMsg: '', - stepIndex: LedgerSteps.CONNECT, + stepIndex: LedgerSteps.Connect, userAddresses: [], addressBalances: [], derivationPath: _.isUndefined(derivationPathIfExists) @@ -67,7 +67,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, <FlatButton key="ledgerConnectCancel" label="Cancel" onClick={this._onClose.bind(this)} />, ]; const dialogTitle = - this.state.stepIndex === LedgerSteps.CONNECT ? 'Connect to your Ledger' : 'Select desired address'; + this.state.stepIndex === LedgerSteps.Connect ? 'Connect to your Ledger' : 'Select desired address'; return ( <Dialog title={dialogTitle} @@ -79,8 +79,8 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, bodyStyle={{ paddingBottom: 0 }} > <div style={{ color: colors.grey700, paddingTop: 1 }}> - {this.state.stepIndex === LedgerSteps.CONNECT && this._renderConnectStep()} - {this.state.stepIndex === LedgerSteps.SELECT_ADDRESS && this._renderSelectAddressStep()} + {this.state.stepIndex === LedgerSteps.Connect && this._renderConnectStep()} + {this.state.stepIndex === LedgerSteps.SelectAddress && this._renderSelectAddressStep()} </div> </Dialog> ); @@ -195,7 +195,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, private _onClose(): void { this.setState({ connectionErrMsg: '', - stepIndex: LedgerSteps.CONNECT, + stepIndex: LedgerSteps.Connect, }); const isOpen = false; this.props.toggleDialogFn(isOpen); @@ -210,7 +210,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, this.props.blockchain.fetchTokenInformationAsync(); this.props.dispatcher.updateUserWeiBalance(selectAddressBalance); this.setState({ - stepIndex: LedgerSteps.CONNECT, + stepIndex: LedgerSteps.Connect, }); const isOpen = false; this.props.toggleDialogFn(isOpen); @@ -284,7 +284,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, const didSucceed = await this._fetchAddressesAndBalancesAsync(); if (didSucceed) { this.setState({ - stepIndex: LedgerSteps.SELECT_ADDRESS, + stepIndex: LedgerSteps.SelectAddress, connectionErrMsg: '', }); } diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index 2fa2b94a0..7fee8c4df 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -182,7 +182,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { </div> )} {!_.isEmpty(this.state.orderJSONErrMsg) && ( - <Alert type={AlertTypes.ERROR} message={this.state.orderJSONErrMsg} /> + <Alert type={AlertTypes.Error} message={this.state.orderJSONErrMsg} /> )} </div> ); @@ -298,7 +298,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { onClick={this._onCancelOrderClickFireAndForgetAsync.bind(this)} /> {this.state.didCancelOrderSucceed && ( - <Alert type={AlertTypes.SUCCESS} message={this._renderCancelSuccessMsg()} /> + <Alert type={AlertTypes.Success} message={this._renderCancelSuccessMsg()} /> )} </div> ) : ( @@ -310,10 +310,10 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { onClick={this._onFillOrderClick.bind(this)} /> {!_.isEmpty(this.state.globalErrMsg) && ( - <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} /> + <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} /> )} {this.state.didFillOrderSucceed && ( - <Alert type={AlertTypes.SUCCESS} message={this._renderFillSuccessMsg()} /> + <Alert type={AlertTypes.Success} message={this._renderFillSuccessMsg()} /> )} </div> )} diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx index e6ecd2ec8..d3f11f962 100644 --- a/packages/website/ts/components/generate_order/asset_picker.tsx +++ b/packages/website/ts/components/generate_order/asset_picker.tsx @@ -18,9 +18,9 @@ import { utils } from 'ts/utils/utils'; const TOKEN_ICON_DIMENSION = 100; const TILE_DIMENSION = 146; enum AssetViews { - ASSET_PICKER = 'ASSET_PICKER', - NEW_TOKEN_FORM = 'NEW_TOKEN_FORM', - CONFIRM_TRACK_TOKEN = 'CONFIRM_TRACK_TOKEN', + AssetPicker = 'ASSET_PICKER', + NewTokenForm = 'NEW_TOKEN_FORM', + ConfirmTrackToken = 'CONFIRM_TRACK_TOKEN', } interface AssetPickerProps { @@ -44,29 +44,29 @@ interface AssetPickerState { export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerState> { public static defaultProps: Partial<AssetPickerProps> = { - tokenVisibility: TokenVisibility.ALL, + tokenVisibility: TokenVisibility.All, }; private readonly _dialogConfigsByAssetView: { [assetView: string]: DialogConfigs }; constructor(props: AssetPickerProps) { super(props); this.state = { - assetView: AssetViews.ASSET_PICKER, + assetView: AssetViews.AssetPicker, hoveredAddress: undefined, chosenTrackTokenAddress: undefined, isAddingTokenToTracked: false, }; this._dialogConfigsByAssetView = { - [AssetViews.ASSET_PICKER]: { + [AssetViews.AssetPicker]: { title: 'Select token', isModal: false, actions: [], }, - [AssetViews.NEW_TOKEN_FORM]: { + [AssetViews.NewTokenForm]: { title: 'Add an ERC20 token', isModal: false, actions: [], }, - [AssetViews.CONFIRM_TRACK_TOKEN]: { + [AssetViews.ConfirmTrackToken]: { title: 'Tracking confirmation', isModal: true, actions: [ @@ -95,15 +95,15 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt autoScrollBodyContent={true} onRequestClose={this._onCloseDialog.bind(this)} > - {this.state.assetView === AssetViews.ASSET_PICKER && this._renderAssetPicker()} - {this.state.assetView === AssetViews.NEW_TOKEN_FORM && ( + {this.state.assetView === AssetViews.AssetPicker && this._renderAssetPicker()} + {this.state.assetView === AssetViews.NewTokenForm && ( <NewTokenForm blockchain={this.props.blockchain} onNewTokenSubmitted={this._onNewTokenSubmitted.bind(this)} tokenByAddress={this.props.tokenByAddress} /> )} - {this.state.assetView === AssetViews.CONFIRM_TRACK_TOKEN && this._renderConfirmTrackToken()} + {this.state.assetView === AssetViews.ConfirmTrackToken && this._renderConfirmTrackToken()} </Dialog> ); } @@ -138,19 +138,19 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt const allTokens = _.values(this.props.tokenByAddress); // filter tokens based on visibility specified in props, do not show ZRX or ETHER as tracked or untracked const filteredTokens = - this.props.tokenVisibility === TokenVisibility.ALL + this.props.tokenVisibility === TokenVisibility.All ? allTokens : _.filter(allTokens, token => { return ( token.symbol !== constants.ZRX_TOKEN_SYMBOL && token.symbol !== constants.ETHER_TOKEN_SYMBOL && - ((this.props.tokenVisibility === TokenVisibility.TRACKED && utils.isTokenTracked(token)) || - (this.props.tokenVisibility === TokenVisibility.UNTRACKED && + ((this.props.tokenVisibility === TokenVisibility.Tracked && utils.isTokenTracked(token)) || + (this.props.tokenVisibility === TokenVisibility.Untracked && !utils.isTokenTracked(token))) ); }); // if we are showing tracked tokens, sort by date added, otherwise sort by symbol - const sortKey = this.props.tokenVisibility === TokenVisibility.TRACKED ? 'trackedTimestamp' : 'symbol'; + const sortKey = this.props.tokenVisibility === TokenVisibility.Tracked ? 'trackedTimestamp' : 'symbol'; const sortedTokens = filteredTokens.sort(firstBy(sortKey)); if (_.isEmpty(sortedTokens)) { return <div className="mx-auto p4 h2">No tokens to remove.</div>; @@ -188,7 +188,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt cursor: 'pointer', opacity: isHovered ? 0.6 : 1, }; - if (this.props.tokenVisibility !== TokenVisibility.TRACKED) { + if (this.props.tokenVisibility !== TokenVisibility.Tracked) { gridTiles.push( <div key={otherTokenKey} @@ -222,7 +222,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt } private _onCloseDialog(): void { this.setState({ - assetView: AssetViews.ASSET_PICKER, + assetView: AssetViews.AssetPicker, }); this.props.onTokenChosen(this.props.currentTokenAddress); } @@ -232,21 +232,21 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt this.props.onTokenChosen(tokenAddress); } else { this.setState({ - assetView: AssetViews.CONFIRM_TRACK_TOKEN, + assetView: AssetViews.ConfirmTrackToken, chosenTrackTokenAddress: tokenAddress, }); } } private _onCustomAssetChosen(): void { this.setState({ - assetView: AssetViews.NEW_TOKEN_FORM, + assetView: AssetViews.NewTokenForm, }); } private _onNewTokenSubmitted(newToken: Token): void { trackedTokenStorage.addTrackedTokenToUser(this.props.userAddress, this.props.networkId, newToken); this.props.dispatcher.addTokenToTokenByAddress(newToken); this.setState({ - assetView: AssetViews.ASSET_PICKER, + assetView: AssetViews.AssetPicker, }); this.props.onTokenChosen(newToken.address); } @@ -254,7 +254,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt const resetState: AssetPickerState = { ...this.state, isAddingTokenToTracked: false, - assetView: AssetViews.ASSET_PICKER, + assetView: AssetViews.AssetPicker, chosenTrackTokenAddress: undefined, }; if (!didUserAcceptTracking) { diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx index 8afbee977..0f70aa18f 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -36,9 +36,9 @@ import { errorReporter } from 'ts/utils/error_reporter'; import { utils } from 'ts/utils/utils'; enum SigningState { - UNSIGNED, - SIGNING, - SIGNED, + Unsigned, + Signing, + Signed, } interface GenerateOrderFormProps { @@ -76,7 +76,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G this.state = { globalErrMsg: '', shouldShowIncompleteErrs: false, - signingState: SigningState.UNSIGNED, + signingState: SigningState.Unsigned, }; } public componentDidMount(): void { @@ -207,7 +207,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G /> </div> {this.state.globalErrMsg !== '' && ( - <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} /> + <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} /> )} </div> </div> @@ -215,7 +215,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G title="Order JSON" titleStyle={{ fontWeight: 100 }} modal={false} - open={this.state.signingState === SigningState.SIGNED} + open={this.state.signingState === SigningState.Signed} onRequestClose={this._onCloseOrderJSONDialog.bind(this)} > <OrderJSON @@ -247,7 +247,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G // orderHash will not collide with the previously generated orderHash. this.props.dispatcher.updateOrderSalt(generatePseudoRandomSalt()); this.setState({ - signingState: SigningState.UNSIGNED, + signingState: SigningState.Unsigned, }); } private async _onSignClickedAsync(): Promise<boolean> { @@ -305,13 +305,13 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G } private async _signTransactionAsync(): Promise<PortalOrder | undefined> { this.setState({ - signingState: SigningState.SIGNING, + signingState: SigningState.Signing, }); const exchangeAddress = this.props.blockchain.getExchangeContractAddressIfExists(); if (_.isUndefined(exchangeAddress)) { this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); this.setState({ - signingState: SigningState.UNSIGNED, + signingState: SigningState.Unsigned, }); return undefined; } @@ -371,7 +371,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G } } this.setState({ - signingState: globalErrMsg === '' ? SigningState.SIGNED : SigningState.UNSIGNED, + signingState: globalErrMsg === '' ? SigningState.Signed : SigningState.Unsigned, globalErrMsg, }); return order; diff --git a/packages/website/ts/components/generate_order/new_token_form.tsx b/packages/website/ts/components/generate_order/new_token_form.tsx index b8cd88b18..ce684d177 100644 --- a/packages/website/ts/components/generate_order/new_token_form.tsx +++ b/packages/website/ts/components/generate_order/new_token_form.tsx @@ -93,7 +93,7 @@ export class NewTokenForm extends React.Component<NewTokenFormProps, NewTokenFor onClickAsyncFn={this._onAddNewTokenClickAsync.bind(this)} /> </div> - {this.state.globalErrMsg !== '' && <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} />} + {this.state.globalErrMsg !== '' && <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} />} </div> ); } diff --git a/packages/website/ts/components/inputs/allowance_state_toggle.tsx b/packages/website/ts/components/inputs/allowance_state_toggle.tsx index 5396295d2..3a78d32f3 100644 --- a/packages/website/ts/components/inputs/allowance_state_toggle.tsx +++ b/packages/website/ts/components/inputs/allowance_state_toggle.tsx @@ -150,7 +150,7 @@ export class AllowanceStateToggle extends React.Component<AllowanceStateTogglePr } logUtils.log(`Unexpected error encountered: ${err}`); logUtils.log(err.stack); - this.props.onErrorOccurred(BalanceErrs.allowanceSettingFailed); + this.props.onErrorOccurred(BalanceErrs.AllowanceSettingFailed); errorReporter.report(err); } } diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 6d7c90573..59cf2db71 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -229,8 +229,8 @@ export class Portal extends React.Component<PortalProps, PortalState> { const isAssetPickerDialogOpen = this.state.tokenManagementState !== TokenManagementState.None; const tokenVisibility = this.state.tokenManagementState === TokenManagementState.Add - ? TokenVisibility.UNTRACKED - : TokenVisibility.TRACKED; + ? TokenVisibility.Untracked + : TokenVisibility.Tracked; return ( <Container> <MetaTags title={DOCUMENT_TITLE} description={DOCUMENT_DESCRIPTION} /> diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index 2ed0229c8..e8f2a6461 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -303,7 +303,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala currentTokenAddress={''} onTokenChosen={this._onAssetTokenPicked.bind(this)} tokenByAddress={this.props.tokenByAddress} - tokenVisibility={this.state.isAddingToken ? TokenVisibility.UNTRACKED : TokenVisibility.TRACKED} + tokenVisibility={this.state.isAddingToken ? TokenVisibility.Untracked : TokenVisibility.Tracked} /> </div> ); @@ -439,7 +439,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala } private _onSendFailed(): void { this.setState({ - errorType: BalanceErrs.sendFailed, + errorType: BalanceErrs.SendFailed, }); } private _renderAmount(amount: BigNumber, decimals: number): React.ReactNode { @@ -460,7 +460,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala } private _renderErrorDialogBody(): React.ReactNode { switch (this.state.errorType) { - case BalanceErrs.incorrectNetworkForFaucet: + case BalanceErrs.IncorrectNetworkForFaucet: return ( <div> Our faucet can only send test Ether to addresses on testnets. Please make sure you are connected @@ -468,7 +468,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala </div> ); - case BalanceErrs.faucetRequestFailed: + case BalanceErrs.FaucetRequestFailed: return ( <div> An unexpected error occurred while trying to request test Ether from our faucet. Please refresh @@ -476,13 +476,13 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala </div> ); - case BalanceErrs.faucetQueueIsFull: + case BalanceErrs.FaucetQueueIsFull: return <div>Our test Ether faucet queue is full. Please try requesting test Ether again later.</div>; - case BalanceErrs.mintingFailed: + case BalanceErrs.MintingFailed: return <div>Minting your test tokens failed unexpectedly. Please refresh the page and try again.</div>; - case BalanceErrs.allowanceSettingFailed: + case BalanceErrs.AllowanceSettingFailed: return ( <div> An unexpected error occurred while trying to set your test token allowance. Please refresh the @@ -521,7 +521,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala logUtils.log(`Unexpected error encountered: ${err}`); logUtils.log(err.stack); this.setState({ - errorType: BalanceErrs.mintingFailed, + errorType: BalanceErrs.MintingFailed, }); errorReporter.report(err); return false; @@ -537,7 +537,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala // from, we must show user an error message if (!utils.isTestNetwork(this.props.blockchain.networkId)) { this.setState({ - errorType: BalanceErrs.incorrectNetworkForFaucet, + errorType: BalanceErrs.IncorrectNetworkForFaucet, }); return false; } @@ -553,8 +553,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala logUtils.log(`Unexpected status code: ${response.status} -> ${responseBody}`); const errorType = response.status === constants.UNAVAILABLE_STATUS - ? BalanceErrs.faucetQueueIsFull - : BalanceErrs.faucetRequestFailed; + ? BalanceErrs.FaucetQueueIsFull + : BalanceErrs.FaucetRequestFailed; this.setState({ errorType, }); diff --git a/packages/website/ts/components/ui/alert.tsx b/packages/website/ts/components/ui/alert.tsx index 32e0f1be8..c7a5b9030 100644 --- a/packages/website/ts/components/ui/alert.tsx +++ b/packages/website/ts/components/ui/alert.tsx @@ -8,7 +8,7 @@ interface AlertProps { } export const Alert = (props: AlertProps) => { - const isAlert = props.type === AlertTypes.ERROR; + const isAlert = props.type === AlertTypes.Error; const errMsgStyles = { background: isAlert ? colors.red200 : colors.lightestGreen, color: colors.white, diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx index a8daf4102..f004dd47f 100644 --- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx +++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx @@ -6,9 +6,9 @@ import * as React from 'react'; const COMPLETE_STATE_SHOW_LENGTH_MS = 2000; enum ButtonState { - READY, - LOADING, - COMPLETE, + Ready, + Loading, + Complete, } interface LifeCycleRaisedButtonProps { @@ -38,7 +38,7 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton constructor(props: LifeCycleRaisedButtonProps) { super(props); this.state = { - buttonState: ButtonState.READY, + buttonState: ButtonState.Ready, }; } public componentWillUnmount(): void { @@ -52,13 +52,13 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton let label; switch (this.state.buttonState) { - case ButtonState.READY: + case ButtonState.Ready: label = this.props.labelReady; break; - case ButtonState.LOADING: + case ButtonState.Loading: label = this.props.labelLoading; break; - case ButtonState.COMPLETE: + case ButtonState.Complete: label = this.props.labelComplete; break; default: @@ -72,13 +72,13 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton backgroundColor={this.props.backgroundColor} labelColor={this.props.labelColor} onClick={this.onClickAsync.bind(this)} - disabled={this.props.isDisabled || this.state.buttonState !== ButtonState.READY} + disabled={this.props.isDisabled || this.state.buttonState !== ButtonState.Ready} /> ); } public async onClickAsync(): Promise<void> { this.setState({ - buttonState: ButtonState.LOADING, + buttonState: ButtonState.Loading, }); const didSucceed = await this.props.onClickAsyncFn(); if (this._didUnmount) { @@ -86,16 +86,16 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton } if (didSucceed) { this.setState({ - buttonState: ButtonState.COMPLETE, + buttonState: ButtonState.Complete, }); this._buttonTimeoutId = window.setTimeout(() => { this.setState({ - buttonState: ButtonState.READY, + buttonState: ButtonState.Ready, }); }, COMPLETE_STATE_SHOW_LENGTH_MS); } else { this.setState({ - buttonState: ButtonState.READY, + buttonState: ButtonState.Ready, }); } } diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index 4ed66c572..7bb018d17 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -31,7 +31,6 @@ import { NextWhy } from 'ts/pages/why'; tradeHistoryStorage.clearIfRequired(); trackedTokenStorage.clearIfRequired(); -import 'basscss/css/basscss.css'; import 'less/all.less'; // We pass modulePromise returning lambda instead of module promise, diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 50114e2d6..9492da5a5 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -83,12 +83,12 @@ export interface Fill { } export enum BalanceErrs { - incorrectNetworkForFaucet, - faucetRequestFailed, - faucetQueueIsFull, - mintingFailed, - sendFailed, - allowanceSettingFailed, + IncorrectNetworkForFaucet, + FaucetRequestFailed, + FaucetQueueIsFull, + MintingFailed, + SendFailed, + AllowanceSettingFailed, } export enum ActionTypes { @@ -209,8 +209,8 @@ export enum ScreenWidths { } export enum AlertTypes { - ERROR, - SUCCESS, + Error, + Success, } export enum BlockchainErrs { @@ -228,11 +228,11 @@ export enum BlockchainCallErrs { } export enum Environments { - DEVELOPMENT = 'DEVELOPMENT', - DOGFOOD = 'DOGFOOD', - STAGING = 'STAGING', - PRODUCTION = 'PRODUCTION', - UNKNOWN = 'UNKNOWN', + Development = 'DEVELOPMENT', + Dogfood = 'DOGFOOD', + Staging = 'STAGING', + Production = 'PRODUCTION', + Unknown = 'UNKNOWN', } export type ContractInstance = any; // TODO: add type definition for Contract @@ -323,9 +323,9 @@ export interface DialogConfigs { } export enum TokenVisibility { - ALL = 'ALL', - UNTRACKED = 'UNTRACKED', - TRACKED = 'TRACKED', + All = 'ALL', + Untracked = 'UNTRACKED', + Tracked = 'TRACKED', } export interface VersionToFilePath { @@ -350,7 +350,7 @@ export enum WebsitePaths { Docs = '/docs', ZeroExJs = '/docs/0x.js', Home = '/', - FAQ = '/faq', + FAQ = '/faq', // tslint:disable-line:enum-naming About = '/about', AboutMission = '/about/mission', AboutTeam = '/about/team', @@ -629,7 +629,7 @@ export enum BrowserType { export enum OperatingSystemType { Android = 'Android', - iOS = 'iOS', + iOS = 'iOS', // tslint:disable-line:enum-naming Mac = 'Mac', Windows = 'Windows', WindowsPhone = 'WindowsPhone', diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 8cc0061de..890f1553a 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -342,18 +342,18 @@ export const utils = { }, getEnvironment(): Environments { if (utils.isDogfood()) { - return Environments.DOGFOOD; + return Environments.Dogfood; } if (utils.isDevelopment()) { - return Environments.DEVELOPMENT; + return Environments.Development; } if (utils.isStaging()) { - return Environments.STAGING; + return Environments.Staging; } if (utils.isProduction()) { - return Environments.PRODUCTION; + return Environments.Production; } - return Environments.UNKNOWN; + return Environments.Unknown; }, getEthToken(tokenByAddress: TokenByAddress): Token { return utils.getTokenBySymbol(constants.ETHER_TOKEN_SYMBOL, tokenByAddress); |