diff options
Diffstat (limited to 'packages/abi-gen-wrappers')
-rw-r--r-- | packages/abi-gen-wrappers/CHANGELOG.json | 12 | ||||
-rw-r--r-- | packages/abi-gen-wrappers/package.json | 2 | ||||
-rw-r--r-- | packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts | 824 | ||||
-rw-r--r-- | packages/abi-gen-wrappers/src/index.ts | 1 |
4 files changed, 837 insertions, 2 deletions
diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json index 028415b9c..7b4d63bf9 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.json +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "2.2.0", + "changes": [ + { + "note": "Added `MultiAssetProxy`", + "pr": 1503 + } + ] + }, + { "timestamp": 1547225310, "version": "2.1.1", "changes": [ @@ -50,7 +59,8 @@ "version": "1.1.0", "changes": [ { - "note": "`deployFrom0xArtifactAsync` additionally accepts artifacts that conform to the `SimpleContractArtifact` interface", + "note": + "`deployFrom0xArtifactAsync` additionally accepts artifacts that conform to the `SimpleContractArtifact` interface", "pr": 1298 } ], diff --git a/packages/abi-gen-wrappers/package.json b/packages/abi-gen-wrappers/package.json index c97810548..14aa64e9e 100644 --- a/packages/abi-gen-wrappers/package.json +++ b/packages/abi-gen-wrappers/package.json @@ -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", 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..b43a345ae --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -0,0 +1,824 @@ +// 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 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public addAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + 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 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 inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; + [target + ] = BaseContract._formatABIDataItemList(inputAbi, [target + ], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([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 inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; + [target + ] = BaseContract._formatABIDataItemList(inputAbi, [target + ], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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; + }, + }; + public authorities = { + async callAsync( + index_0: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public getAssetProxy = { + async callAsync( + assetProxyId: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public removeAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + 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 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 inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; + [target + ] = BaseContract._formatABIDataItemList(inputAbi, [target + ], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([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 inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; + [target + ] = BaseContract._formatABIDataItemList(inputAbi, [target + ], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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; + }, + }; + public owner = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public removeAuthorizedAddressAtIndex = { + async sendTransactionAsync( + target: string, + index: BigNumber, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + 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, + 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 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, + 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 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, + index + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + index: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + 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, + 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); + 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; + }, + }; + public getProxyId = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public authorized = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<boolean + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public registerAssetProxy = { + async sendTransactionAsync( + assetProxy: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + 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 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 inputAbi = self._lookupAbi('registerAssetProxy(address)').inputs; + [assetProxy + ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy + ], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('registerAssetProxy(address)').functions.registerAssetProxy.encode([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 inputAbi = self._lookupAbi('registerAssetProxy(address)').inputs; + [assetProxy + ] = BaseContract._formatABIDataItemList(inputAbi, [assetProxy + ], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self._lookupEthersInterface('registerAssetProxy(address)').functions.registerAssetProxy.encode([assetProxy + ]); + return abiEncodedTransactionData; + }, + async callAsync( + assetProxy: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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; + }, + }; + public getAuthorizedAddresses = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<string[] + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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]; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + txData: Partial<TxData> = {}, + ): Promise<string> { + const self = this as any as MultiAssetProxyContract; + 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 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 inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner + ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner + ], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([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 inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner + ] = BaseContract._formatABIDataItemList(inputAbi, [newOwner + ], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): Promise<void + > { + const self = this as any as MultiAssetProxyContract; + 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 callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + 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; + }, + }; + 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, ['_ethersInterfacesByFunctionSignature', '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'; |