diff options
Diffstat (limited to 'packages/abi-gen-wrappers')
21 files changed, 13037 insertions, 0 deletions
diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json new file mode 100644 index 000000000..c3273536b --- /dev/null +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -0,0 +1,29 @@ +[ + { + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1541740904 + }, + { + "timestamp": 1539871071, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "1.0.0", + "changes": [ + { + "pr": 1105, + "note": "Initial release" + } + ] + } +] diff --git a/packages/abi-gen-wrappers/CHANGELOG.md b/packages/abi-gen-wrappers/CHANGELOG.md new file mode 100644 index 000000000..18bd28cb8 --- /dev/null +++ b/packages/abi-gen-wrappers/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 - _November 9, 2018_ + + * Dependencies updated + +## v1.0.1 - _October 18, 2018_ + + * Dependencies updated + +## v1.0.0 - _Invalid date_ + + * Initial release (#1105) diff --git a/packages/abi-gen-wrappers/README.md b/packages/abi-gen-wrappers/README.md new file mode 100644 index 000000000..bcf58ae06 --- /dev/null +++ b/packages/abi-gen-wrappers/README.md @@ -0,0 +1,73 @@ +## @0x/abi-gen-wrappers + +Low-level 0x smart contract wrappers generated using @0x/abi-gen. These +low-level wrappers are imported by other packages in the 0x monorepo and +application developers are not expected to import this package directly. + +You may also be interested in the +[@0x/contract-wrappers](../contract-wrappers/README.md) package which +includes some higher-level features. + +## Installation + +```bash +yarn add @0x/abi-gen-wrappers +``` + +**Import** + +```typescript +import * as wrappers from '@0x/abi-gen-wrappers'; +``` + +or + +```javascript +var wrappers = require('@0x/abi-gen-wrappers'); +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/abi-gen-wrappers yarn build +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/abi-gen-wrappers/package.json b/packages/abi-gen-wrappers/package.json new file mode 100644 index 000000000..a4316449f --- /dev/null +++ b/packages/abi-gen-wrappers/package.json @@ -0,0 +1,48 @@ +{ + "name": "@0x/abi-gen-wrappers", + "version": "1.0.2", + "engines": { + "node": ">=6.12" + }, + "description": "Low-level 0x smart contract wrappers generated using @0x/abi-gen", + "main": "lib/src/index.js", + "directories": { + "test": "test" + }, + "scripts": { + "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", + "lint": "tslint --format stylish --project .", + "pre_build": "yarn generate_contract_wrappers", + "clean": "shx rm -rf lib wrappers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers" + }, + "config": { + "abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|ZRXToken).json" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md", + "devDependencies": { + "@0x/abi-gen": "^1.0.15", + "@0x/tslint-config": "^1.0.10", + "@0x/utils": "^2.0.4", + "@0x/web3-wrapper": "^3.1.1", + "ethereum-types": "^1.1.2", + "ethers": "~4.0.4", + "lodash": "^4.17.5", + "shx": "^0.2.2" + }, + "dependencies": { + "@0x/base-contract": "^3.0.3" + }, + "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 new file mode 100644 index 000000000..8ca70e026 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -0,0 +1,1876 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type AssetProxyOwnerEventArgs = + | AssetProxyOwnerAssetProxyRegistrationEventArgs + | AssetProxyOwnerConfirmationTimeSetEventArgs + | AssetProxyOwnerTimeLockChangeEventArgs + | AssetProxyOwnerConfirmationEventArgs + | AssetProxyOwnerRevocationEventArgs + | AssetProxyOwnerSubmissionEventArgs + | AssetProxyOwnerExecutionEventArgs + | AssetProxyOwnerExecutionFailureEventArgs + | AssetProxyOwnerDepositEventArgs + | AssetProxyOwnerOwnerAdditionEventArgs + | AssetProxyOwnerOwnerRemovalEventArgs + | AssetProxyOwnerRequirementChangeEventArgs; + +export enum AssetProxyOwnerEvents { + AssetProxyRegistration = 'AssetProxyRegistration', + ConfirmationTimeSet = 'ConfirmationTimeSet', + TimeLockChange = 'TimeLockChange', + Confirmation = 'Confirmation', + Revocation = 'Revocation', + Submission = 'Submission', + Execution = 'Execution', + ExecutionFailure = 'ExecutionFailure', + Deposit = 'Deposit', + OwnerAddition = 'OwnerAddition', + OwnerRemoval = 'OwnerRemoval', + RequirementChange = 'RequirementChange', +} + +export interface AssetProxyOwnerAssetProxyRegistrationEventArgs extends DecodedLogArgs { + assetProxyContract: string; + isRegistered: boolean; +} + +export interface AssetProxyOwnerConfirmationTimeSetEventArgs extends DecodedLogArgs { + transactionId: BigNumber; + confirmationTime: BigNumber; +} + +export interface AssetProxyOwnerTimeLockChangeEventArgs extends DecodedLogArgs { + secondsTimeLocked: BigNumber; +} + +export interface AssetProxyOwnerConfirmationEventArgs extends DecodedLogArgs { + sender: string; + transactionId: BigNumber; +} + +export interface AssetProxyOwnerRevocationEventArgs extends DecodedLogArgs { + sender: string; + transactionId: BigNumber; +} + +export interface AssetProxyOwnerSubmissionEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface AssetProxyOwnerExecutionEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface AssetProxyOwnerExecutionFailureEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface AssetProxyOwnerDepositEventArgs extends DecodedLogArgs { + sender: string; + value: BigNumber; +} + +export interface AssetProxyOwnerOwnerAdditionEventArgs extends DecodedLogArgs { + owner: string; +} + +export interface AssetProxyOwnerOwnerRemovalEventArgs extends DecodedLogArgs { + owner: string; +} + +export interface AssetProxyOwnerRequirementChangeEventArgs extends DecodedLogArgs { + required: BigNumber; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class AssetProxyOwnerContract extends BaseContract { + public owners = { + async callAsync( + index_0: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public removeOwner = { + async sendTransactionAsync( + owner: string, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.removeOwner.estimateGasAsync.bind( + self, + owner + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + owner: string, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'removeOwner'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public revokeConfirmation = { + async sendTransactionAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.revokeConfirmation.estimateGasAsync.bind( + self, + transactionId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'revokeConfirmation'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public isOwner = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public confirmations = { + async callAsync( + index_0: BigNumber, + index_1: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + index_1 + ]); + 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: '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]; + }, + }; + public executeRemoveAuthorizedAddressAtIndex = { + async sendTransactionAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.executeRemoveAuthorizedAddressAtIndex.estimateGasAsync.bind( + self, + transactionId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'executeRemoveAuthorizedAddressAtIndex'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public secondsTimeLocked = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public getTransactionCount = { + async callAsync( + pending: boolean, + executed: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + executed + ]); + 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: '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]; + }, + }; + public registerAssetProxy = { + async sendTransactionAsync( + assetProxyContract: string, + isRegistered: boolean, + 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, + isRegistered + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.registerAssetProxy.estimateGasAsync.bind( + self, + assetProxyContract, + isRegistered + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + assetProxyContract: string, + isRegistered: boolean, + 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, + isRegistered + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + assetProxyContract: string, + 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, + isRegistered + ]); + return abiEncodedTransactionData; + }, + async callAsync( + assetProxyContract: string, + isRegistered: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + isRegistered + ]); + 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 addOwner = { + async sendTransactionAsync( + owner: string, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.addOwner.estimateGasAsync.bind( + self, + owner + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + owner: string, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'addOwner'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public isConfirmed = { + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public changeTimeLock = { + async sendTransactionAsync( + _secondsTimeLocked: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.changeTimeLock.estimateGasAsync.bind( + self, + _secondsTimeLocked + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _secondsTimeLocked: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _secondsTimeLocked: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'changeTimeLock'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public isAssetProxyRegistered = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public getConfirmationCount = { + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transactions = { + async callAsync( + index_0: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'transactions'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public getOwners = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public getTransactionIds = { + async callAsync( + from: BigNumber, + to: BigNumber, + pending: boolean, + executed: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + to, + pending, + executed + ]); + 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: '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]; + }, + }; + public getConfirmations = { + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transactionCount = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public changeRequirement = { + async sendTransactionAsync( + _required: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.changeRequirement.estimateGasAsync.bind( + self, + _required + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _required: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _required: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'changeRequirement'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public confirmTransaction = { + async sendTransactionAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.confirmTransaction.estimateGasAsync.bind( + self, + transactionId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'confirmTransaction'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public submitTransaction = { + async sendTransactionAsync( + destination: string, + value: BigNumber, + data: string, + 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, + value, + data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.submitTransaction.estimateGasAsync.bind( + self, + destination, + value, + data + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + destination: string, + value: BigNumber, + data: string, + 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, + value, + data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + destination: string, + value: BigNumber, + 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, + value, + data + ]); + return abiEncodedTransactionData; + }, + async callAsync( + destination: string, + value: BigNumber, + data: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + value, + data + ]); + 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: '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]; + }, + }; + public confirmationTimes = { + async callAsync( + index_0: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public MAX_OWNER_COUNT = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public required = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public replaceOwner = { + async sendTransactionAsync( + owner: string, + newOwner: string, + 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, + newOwner + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.replaceOwner.estimateGasAsync.bind( + self, + owner, + newOwner + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + owner: string, + newOwner: string, + 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, + 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( + owner: string, + 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, + newOwner + ]); + return abiEncodedTransactionData; + }, + async callAsync( + owner: string, + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + 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: 'replaceOwner'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public executeTransaction = { + async sendTransactionAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.executeTransaction.estimateGasAsync.bind( + self, + transactionId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + transactionId: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'executeTransaction'}) 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, + provider: Provider, + txDefaults: Partial<TxData>, + _owners: string[], + _assetProxyContracts: string[], + _required: BigNumber, + _secondsTimeLocked: BigNumber, + ): Promise<AssetProxyOwnerContract> { + 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 AssetProxyOwnerContract.deployAsync(bytecode, abi, provider, txDefaults, _owners, +_assetProxyContracts, +_required, +_secondsTimeLocked +); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + _owners: string[], + _assetProxyContracts: string[], + _required: BigNumber, + _secondsTimeLocked: BigNumber, + ): Promise<AssetProxyOwnerContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_owners, +_assetProxyContracts, +_required, +_secondsTimeLocked +] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_owners, +_assetProxyContracts, +_required, +_secondsTimeLocked +], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_owners, +_assetProxyContracts, +_required, +_secondsTimeLocked +]); + 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(`AssetProxyOwner successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new AssetProxyOwnerContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = [_owners, +_assetProxyContracts, +_required, +_secondsTimeLocked +]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('AssetProxyOwner', 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/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts new file mode 100644 index 000000000..1efeeed0a --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -0,0 +1,1044 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type DummyERC20TokenEventArgs = + | DummyERC20TokenTransferEventArgs + | DummyERC20TokenApprovalEventArgs; + +export enum DummyERC20TokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', +} + +export interface DummyERC20TokenTransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface DummyERC20TokenApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class DummyERC20TokenContract extends BaseContract { + public name = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public approve = { + async sendTransactionAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + _spender, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _spender: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _spender: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public totalSupply = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _value + ]); + 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: '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]; + }, + }; + public decimals = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public owner = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 symbol = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public mint = { + async sendTransactionAsync( + _value: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.mint.estimateGasAsync.bind( + self, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _value: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'mint'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public transfer = { + async sendTransactionAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transfer.estimateGasAsync.bind( + self, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _spender + ]); + 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: '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]; + }, + }; + public setBalance = { + async sendTransactionAsync( + _target: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.setBalance.estimateGasAsync.bind( + self, + _target, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _target: string, + _value: BigNumber, + 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, + _value + ]); + 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, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _target: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: 'setBalance'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 MAX_MINT_AMOUNT = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + _name: string, + _symbol: string, + _decimals: BigNumber, + _totalSupply: BigNumber, + ): Promise<DummyERC20TokenContract> { + 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 DummyERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, _name, +_symbol, +_decimals, +_totalSupply +); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + _name: string, + _symbol: string, + _decimals: BigNumber, + _totalSupply: BigNumber, + ): Promise<DummyERC20TokenContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_name, +_symbol, +_decimals, +_totalSupply +] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_name, +_symbol, +_decimals, +_totalSupply +], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_name, +_symbol, +_decimals, +_totalSupply +]); + 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(`DummyERC20Token successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new DummyERC20TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = [_name, +_symbol, +_decimals, +_totalSupply +]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('DummyERC20Token', 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/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts new file mode 100644 index 000000000..cc5f9679f --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -0,0 +1,1326 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type DummyERC721TokenEventArgs = + | DummyERC721TokenTransferEventArgs + | DummyERC721TokenApprovalEventArgs + | DummyERC721TokenApprovalForAllEventArgs; + +export enum DummyERC721TokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', + ApprovalForAll = 'ApprovalForAll', +} + +export interface DummyERC721TokenTransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _tokenId: BigNumber; +} + +export interface DummyERC721TokenApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _approved: string; + _tokenId: BigNumber; +} + +export interface DummyERC721TokenApprovalForAllEventArgs extends DecodedLogArgs { + _owner: string; + _operator: string; + _approved: boolean; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class DummyERC721TokenContract extends BaseContract { + public name = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public getApproved = { + async callAsync( + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public approve = { + async sendTransactionAsync( + _approved: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + _approved, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _approved: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _approved: string, + _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, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _approved: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _tokenId + ]); + 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: 'approve'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId + ]); + 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: 'transferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public mint = { + async sendTransactionAsync( + _to: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.mint.estimateGasAsync.bind( + self, + _to, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _to: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _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, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _tokenId + ]); + 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: 'mint'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public safeTransferFrom1 = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.safeTransferFrom1.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId + ]); + 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: 'safeTransferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public ownerOf = { + async callAsync( + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public owner = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 symbol = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public burn = { + async sendTransactionAsync( + _owner: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.burn.estimateGasAsync.bind( + self, + _owner, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _owner: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _owner: string, + _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, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _owner: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _tokenId + ]); + 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: 'burn'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public setApprovalForAll = { + async sendTransactionAsync( + _operator: string, + _approved: boolean, + 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, + _approved + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.setApprovalForAll.estimateGasAsync.bind( + self, + _operator, + _approved + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _operator: string, + _approved: boolean, + 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, + _approved + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _operator: string, + _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, + _approved + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _operator: string, + _approved: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _approved + ]); + 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: 'setApprovalForAll'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public safeTransferFrom2 = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + 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, + _to, + _tokenId, + _data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.safeTransferFrom2.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId, + _data + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + 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, + _to, + _tokenId, + _data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _tokenId: BigNumber, + _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, + _to, + _tokenId, + _data + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId, + _data + ]); + 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: 'safeTransferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public isApprovedForAll = { + async callAsync( + _owner: string, + _operator: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _operator + ]); + 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: '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]; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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, + provider: Provider, + txDefaults: Partial<TxData>, + _name: string, + _symbol: string, + ): Promise<DummyERC721TokenContract> { + 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 DummyERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, _name, +_symbol +); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + _name: string, + _symbol: string, + ): Promise<DummyERC721TokenContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_name, +_symbol +] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_name, +_symbol +], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_name, +_symbol +]); + 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(`DummyERC721Token successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new DummyERC721TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = [_name, +_symbol +]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('DummyERC721Token', 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/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts new file mode 100644 index 000000000..ab207b38e --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -0,0 +1,649 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ERC20ProxyEventArgs = + | ERC20ProxyAuthorizedAddressAddedEventArgs + | ERC20ProxyAuthorizedAddressRemovedEventArgs; + +export enum ERC20ProxyEvents { + AuthorizedAddressAdded = 'AuthorizedAddressAdded', + AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', +} + +export interface ERC20ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + +export interface ERC20ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ERC20ProxyContract extends BaseContract { + public addAuthorizedAddress = { + async sendTransactionAsync( + target: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 removeAuthorizedAddress = { + async sendTransactionAsync( + target: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 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, + 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 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, + 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 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, + index + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + index: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + 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 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 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 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 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 getAuthorizedAddresses = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC20ProxyContract> { + 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 ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC20ProxyContract> { + 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(`ERC20Proxy successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ERC20ProxyContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('ERC20Proxy', 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/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts new file mode 100644 index 000000000..8ee563b7e --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -0,0 +1,556 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ERC20TokenEventArgs = + | ERC20TokenTransferEventArgs + | ERC20TokenApprovalEventArgs; + +export enum ERC20TokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', +} + +export interface ERC20TokenTransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ERC20TokenContract extends BaseContract { + public approve = { + async sendTransactionAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + _spender, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _spender: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _spender: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public totalSupply = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _value + ]); + 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transfer = { + async sendTransactionAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transfer.estimateGasAsync.bind( + self, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _spender + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC20TokenContract> { + 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 ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC20TokenContract> { + 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(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ERC20TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('ERC20Token', 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/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts new file mode 100644 index 000000000..691c55578 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -0,0 +1,649 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ERC721ProxyEventArgs = + | ERC721ProxyAuthorizedAddressAddedEventArgs + | ERC721ProxyAuthorizedAddressRemovedEventArgs; + +export enum ERC721ProxyEvents { + AuthorizedAddressAdded = 'AuthorizedAddressAdded', + AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', +} + +export interface ERC721ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + +export interface ERC721ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { + target: string; + caller: string; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ERC721ProxyContract extends BaseContract { + public addAuthorizedAddress = { + async sendTransactionAsync( + target: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 removeAuthorizedAddress = { + async sendTransactionAsync( + target: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 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, + 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 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, + 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 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, + index + ]); + return abiEncodedTransactionData; + }, + async callAsync( + target: string, + index: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + 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 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 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 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 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 getAuthorizedAddresses = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC721ProxyContract> { + 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 ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC721ProxyContract> { + 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(`ERC721Proxy successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ERC721ProxyContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('ERC721Proxy', 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/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts new file mode 100644 index 000000000..d1a2d5670 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -0,0 +1,893 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ERC721TokenEventArgs = + | ERC721TokenTransferEventArgs + | ERC721TokenApprovalEventArgs + | ERC721TokenApprovalForAllEventArgs; + +export enum ERC721TokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', + ApprovalForAll = 'ApprovalForAll', +} + +export interface ERC721TokenTransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _tokenId: BigNumber; +} + +export interface ERC721TokenApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _approved: string; + _tokenId: BigNumber; +} + +export interface ERC721TokenApprovalForAllEventArgs extends DecodedLogArgs { + _owner: string; + _operator: string; + _approved: boolean; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ERC721TokenContract extends BaseContract { + public getApproved = { + async callAsync( + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public approve = { + async sendTransactionAsync( + _approved: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + _approved, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _approved: string, + _tokenId: BigNumber, + 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, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _approved: string, + _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, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _approved: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _tokenId + ]); + 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: 'approve'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId + ]); + 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: 'transferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public safeTransferFrom1 = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.safeTransferFrom1.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + 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, + _to, + _tokenId + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _tokenId + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId + ]); + 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: 'safeTransferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public ownerOf = { + async callAsync( + _tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public setApprovalForAll = { + async sendTransactionAsync( + _operator: string, + _approved: boolean, + 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, + _approved + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.setApprovalForAll.estimateGasAsync.bind( + self, + _operator, + _approved + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _operator: string, + _approved: boolean, + 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, + _approved + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _operator: string, + _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, + _approved + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _operator: string, + _approved: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _approved + ]); + 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: 'setApprovalForAll'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public safeTransferFrom2 = { + async sendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + 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, + _to, + _tokenId, + _data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.safeTransferFrom2.estimateGasAsync.bind( + self, + _from, + _to, + _tokenId, + _data + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + 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, + _to, + _tokenId, + _data + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _tokenId: BigNumber, + _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, + _to, + _tokenId, + _data + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _tokenId, + _data + ]); + 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: 'safeTransferFrom'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public isApprovedForAll = { + async callAsync( + _owner: string, + _operator: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _operator + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC721TokenContract> { + 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 ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ERC721TokenContract> { + 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(`ERC721Token successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ERC721TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('ERC721Token', 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/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts new file mode 100644 index 000000000..ffd498055 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -0,0 +1,3072 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ExchangeEventArgs = + | ExchangeSignatureValidatorApprovalEventArgs + | ExchangeFillEventArgs + | ExchangeCancelEventArgs + | ExchangeCancelUpToEventArgs + | ExchangeAssetProxyRegisteredEventArgs; + +export enum ExchangeEvents { + SignatureValidatorApproval = 'SignatureValidatorApproval', + Fill = 'Fill', + Cancel = 'Cancel', + CancelUpTo = 'CancelUpTo', + AssetProxyRegistered = 'AssetProxyRegistered', +} + +export interface ExchangeSignatureValidatorApprovalEventArgs extends DecodedLogArgs { + signerAddress: string; + validatorAddress: string; + approved: boolean; +} + +export interface ExchangeFillEventArgs extends DecodedLogArgs { + makerAddress: string; + feeRecipientAddress: string; + takerAddress: string; + senderAddress: string; + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + orderHash: string; + makerAssetData: string; + takerAssetData: string; +} + +export interface ExchangeCancelEventArgs extends DecodedLogArgs { + makerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + orderHash: string; + makerAssetData: string; + takerAssetData: string; +} + +export interface ExchangeCancelUpToEventArgs extends DecodedLogArgs { + makerAddress: string; + senderAddress: string; + orderEpoch: BigNumber; +} + +export interface ExchangeAssetProxyRegisteredEventArgs extends DecodedLogArgs { + id: string; + assetProxy: string; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ExchangeContract extends BaseContract { + public filled = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public batchFillOrders = { + async sendTransactionAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.batchFillOrders.estimateGasAsync.bind( + self, + orders, + takerAssetFillAmounts, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + takerAssetFillAmounts: BigNumber[], + 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, + takerAssetFillAmounts, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmounts, + signatures + ]); + 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: '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]; + }, + }; + public cancelled = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public preSign = { + async sendTransactionAsync( + hash: string, + signerAddress: string, + signature: string, + 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, + signerAddress, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.preSign.estimateGasAsync.bind( + self, + hash, + signerAddress, + signature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + hash: string, + signerAddress: string, + signature: string, + 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, + signerAddress, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + hash: string, + signerAddress: string, + 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, + signerAddress, + signature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + hash: string, + signerAddress: string, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signerAddress, + signature + ]); + 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: 'preSign'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public matchOrders = { + async sendTransactionAsync( + leftOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + rightOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + leftSignature: string, + rightSignature: string, + 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, + rightOrder, + leftSignature, + rightSignature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.matchOrders.estimateGasAsync.bind( + self, + leftOrder, + rightOrder, + leftSignature, + rightSignature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + leftOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + rightOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + leftSignature: string, + rightSignature: string, + 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, + rightOrder, + leftSignature, + rightSignature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + leftOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + rightOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + leftSignature: string, + 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, + rightOrder, + leftSignature, + rightSignature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + leftOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + rightOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}, + leftSignature: string, + rightSignature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + rightOrder, + leftSignature, + rightSignature + ]); + 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: '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]; + }, + }; + public fillOrderNoThrow = { + async sendTransactionAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.fillOrderNoThrow.estimateGasAsync.bind( + self, + order, + takerAssetFillAmount, + signature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}, + takerAssetFillAmount: BigNumber, + 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, + takerAssetFillAmount, + signature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmount, + signature + ]); + 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: '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]; + }, + }; + public assetProxies = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 batchCancelOrders = { + async sendTransactionAsync( + 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}>, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.batchCancelOrders.estimateGasAsync.bind( + self, + orders + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'batchCancelOrders'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public batchFillOrKillOrders = { + async sendTransactionAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.batchFillOrKillOrders.estimateGasAsync.bind( + self, + orders, + takerAssetFillAmounts, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + takerAssetFillAmounts: BigNumber[], + 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, + takerAssetFillAmounts, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmounts, + signatures + ]); + 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: '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]; + }, + }; + public cancelOrdersUpTo = { + async sendTransactionAsync( + targetOrderEpoch: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.cancelOrdersUpTo.estimateGasAsync.bind( + self, + targetOrderEpoch + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + targetOrderEpoch: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + targetOrderEpoch: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'cancelOrdersUpTo'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public batchFillOrdersNoThrow = { + async sendTransactionAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.batchFillOrdersNoThrow.estimateGasAsync.bind( + self, + orders, + takerAssetFillAmounts, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + 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, + takerAssetFillAmounts, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + takerAssetFillAmounts: BigNumber[], + 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, + takerAssetFillAmounts, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmounts, + signatures + ]); + 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: '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]; + }, + }; + public getAssetProxy = { + async callAsync( + assetProxyId: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 transactions = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public fillOrKillOrder = { + async sendTransactionAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.fillOrKillOrder.estimateGasAsync.bind( + self, + order, + takerAssetFillAmount, + signature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}, + takerAssetFillAmount: BigNumber, + 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, + takerAssetFillAmount, + signature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmount, + signature + ]); + 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: '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]; + }, + }; + public setSignatureValidatorApproval = { + async sendTransactionAsync( + validatorAddress: string, + approval: boolean, + 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, + approval + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.setSignatureValidatorApproval.estimateGasAsync.bind( + self, + validatorAddress, + approval + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + validatorAddress: string, + approval: boolean, + 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, + approval + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + validatorAddress: string, + 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, + approval + ]); + return abiEncodedTransactionData; + }, + async callAsync( + validatorAddress: string, + approval: boolean, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + approval + ]); + 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: 'setSignatureValidatorApproval'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public allowedValidators = { + async callAsync( + index_0: string, + index_1: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + index_1 + ]); + 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: '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]; + }, + }; + public marketSellOrders = { + async sendTransactionAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + 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, + takerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketSellOrders.estimateGasAsync.bind( + self, + orders, + takerAssetFillAmount, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + 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, + takerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + takerAssetFillAmount: BigNumber, + 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, + takerAssetFillAmount, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmount, + signatures + ]); + 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: '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]; + }, + }; + public getOrdersInfo = { + async callAsync( + 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}>, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public preSigned = { + async callAsync( + index_0: string, + index_1: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + index_1 + ]); + 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: '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]; + }, + }; + public owner = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 isValidSignature = { + async callAsync( + hash: string, + signerAddress: string, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signerAddress, + signature + ]); + 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: '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]; + }, + }; + public marketBuyOrdersNoThrow = { + async sendTransactionAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + 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, + makerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketBuyOrdersNoThrow.estimateGasAsync.bind( + self, + orders, + makerAssetFillAmount, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + 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, + makerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + makerAssetFillAmount: BigNumber, + 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, + makerAssetFillAmount, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + makerAssetFillAmount, + signatures + ]); + 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: '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]; + }, + }; + public fillOrder = { + async sendTransactionAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.fillOrder.estimateGasAsync.bind( + self, + order, + takerAssetFillAmount, + signature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + 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, + takerAssetFillAmount, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}, + takerAssetFillAmount: BigNumber, + 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, + takerAssetFillAmount, + signature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}, + takerAssetFillAmount: BigNumber, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmount, + signature + ]); + 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: '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]; + }, + }; + public executeTransaction = { + async sendTransactionAsync( + salt: BigNumber, + signerAddress: string, + data: string, + signature: string, + 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, + signerAddress, + data, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.executeTransaction.estimateGasAsync.bind( + self, + salt, + signerAddress, + data, + signature + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + salt: BigNumber, + signerAddress: string, + data: string, + signature: string, + 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, + signerAddress, + data, + signature + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + salt: BigNumber, + signerAddress: string, + data: string, + 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, + signerAddress, + data, + signature + ]); + return abiEncodedTransactionData; + }, + async callAsync( + salt: BigNumber, + signerAddress: string, + data: string, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signerAddress, + data, + signature + ]); + 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: 'executeTransaction'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public registerAssetProxy = { + async sendTransactionAsync( + assetProxy: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + assetProxy: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 getOrderInfo = { + async callAsync( + 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}, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public cancelOrder = { + async sendTransactionAsync( + 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}, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.cancelOrder.estimateGasAsync.bind( + self, + order + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'cancelOrder'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public orderEpoch = { + async callAsync( + index_0: string, + index_1: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + index_1 + ]); + 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: '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]; + }, + }; + public ZRX_ASSET_DATA = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public marketSellOrdersNoThrow = { + async sendTransactionAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + 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, + takerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketSellOrdersNoThrow.estimateGasAsync.bind( + self, + orders, + takerAssetFillAmount, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + 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, + takerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + takerAssetFillAmount: BigNumber, + 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, + takerAssetFillAmount, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + takerAssetFillAmount: BigNumber, + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAssetFillAmount, + signatures + ]); + 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: '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]; + }, + }; + public EIP712_DOMAIN_HASH = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public marketBuyOrders = { + async sendTransactionAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + 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, + makerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketBuyOrders.estimateGasAsync.bind( + self, + orders, + makerAssetFillAmount, + signatures + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + 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, + makerAssetFillAmount, + signatures + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + makerAssetFillAmount: BigNumber, + 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, + makerAssetFillAmount, + signatures + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + makerAssetFillAmount, + signatures + ]); + 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: '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]; + }, + }; + public currentContextAddress = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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 VERSION = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ExchangeContract> { + 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 ExchangeContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ExchangeContract> { + 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(`Exchange successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ExchangeContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('Exchange', 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/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts new file mode 100644 index 000000000..80bbc52c7 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -0,0 +1,730 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ForwarderContract extends BaseContract { + public marketBuyOrdersWithEth = { + async sendTransactionAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + 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, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketBuyOrdersWithEth.estimateGasAsync.bind( + self, + orders, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + 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, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + 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, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + makerAssetFillAmount: BigNumber, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + 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: 'marketBuyOrdersWithEth'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public withdrawAsset = { + async sendTransactionAsync( + assetData: string, + amount: BigNumber, + 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, + amount + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.withdrawAsset.estimateGasAsync.bind( + self, + assetData, + amount + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + assetData: string, + amount: BigNumber, + 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, + amount + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + assetData: string, + 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, + amount + ]); + return abiEncodedTransactionData; + }, + async callAsync( + assetData: string, + amount: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + amount + ]); + 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: 'withdrawAsset'}) 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 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 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 marketSellOrdersWithEth = { + async sendTransactionAsync( + 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}>, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + 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, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.marketSellOrdersWithEth.estimateGasAsync.bind( + self, + orders, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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}>, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + 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, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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}>, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + 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, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + return abiEncodedTransactionData; + }, + async callAsync( + 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}>, + signatures: string[], + feeOrders: 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}>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient + ]); + 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: 'marketSellOrdersWithEth'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + 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 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 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 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 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + newOwner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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, + provider: Provider, + txDefaults: Partial<TxData>, + _exchange: string, + _zrxAssetData: string, + _wethAssetData: string, + ): Promise<ForwarderContract> { + 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 ForwarderContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange, +_zrxAssetData, +_wethAssetData +); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + _exchange: string, + _zrxAssetData: string, + _wethAssetData: string, + ): Promise<ForwarderContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_exchange, +_zrxAssetData, +_wethAssetData +] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_exchange, +_zrxAssetData, +_wethAssetData +], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_exchange, +_zrxAssetData, +_wethAssetData +]); + 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(`Forwarder successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ForwarderContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = [_exchange, +_zrxAssetData, +_wethAssetData +]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('Forwarder', 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/generated-wrappers/i_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts new file mode 100644 index 000000000..203a66b6d --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts @@ -0,0 +1,108 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class IValidatorContract extends BaseContract { + public isValidSignature = { + async callAsync( + hash: string, + signerAddress: string, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signerAddress, + signature + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<IValidatorContract> { + 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 IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<IValidatorContract> { + 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(`IValidator successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new IValidatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('IValidator', 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/generated-wrappers/i_wallet.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts new file mode 100644 index 000000000..99809a049 --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts @@ -0,0 +1,103 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class IWalletContract extends BaseContract { + public isValidSignature = { + async callAsync( + hash: string, + signature: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + signature + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<IWalletContract> { + 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 IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<IWalletContract> { + 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(`IWallet successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new IWalletContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('IWallet', 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/generated-wrappers/order_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts new file mode 100644 index 000000000..38233af3f --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts @@ -0,0 +1,357 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class OrderValidatorContract extends BaseContract { + public getOrderAndTraderInfo = { + async callAsync( + 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}, + takerAddress: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAddress + ]); + 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: 'getOrderAndTraderInfo'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public getBalanceAndAllowance = { + async callAsync( + target: string, + assetData: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + assetData + ]); + 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: 'getBalanceAndAllowance'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public getOrdersAndTradersInfo = { + async callAsync( + 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}>, + takerAddresses: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAddresses + ]); + 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: 'getOrdersAndTradersInfo'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public getTradersInfo = { + async callAsync( + 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}>, + takerAddresses: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAddresses + ]); + 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: '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]; + }, + }; + public getERC721TokenOwner = { + async callAsync( + token: string, + tokenId: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + tokenId + ]); + 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: '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]; + }, + }; + public getBalancesAndAllowances = { + async callAsync( + target: string, + assetData: string[], + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + assetData + ]); + 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: 'getBalancesAndAllowances'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public getTraderInfo = { + async callAsync( + 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}, + takerAddress: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + takerAddress + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + _exchange: string, + _zrxAssetData: string, + ): Promise<OrderValidatorContract> { + 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 OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange, +_zrxAssetData +); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + _exchange: string, + _zrxAssetData: string, + ): Promise<OrderValidatorContract> { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_exchange, +_zrxAssetData +] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_exchange, +_zrxAssetData +], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_exchange, +_zrxAssetData +]); + 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(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new OrderValidatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = [_exchange, +_zrxAssetData +]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('OrderValidator', 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/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts new file mode 100644 index 000000000..86d1031db --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -0,0 +1,835 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type WETH9EventArgs = + | WETH9ApprovalEventArgs + | WETH9TransferEventArgs + | WETH9DepositEventArgs + | WETH9WithdrawalEventArgs; + +export enum WETH9Events { + Approval = 'Approval', + Transfer = 'Transfer', + Deposit = 'Deposit', + Withdrawal = 'Withdrawal', +} + +export interface WETH9ApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + +export interface WETH9TransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface WETH9DepositEventArgs extends DecodedLogArgs { + _owner: string; + _value: BigNumber; +} + +export interface WETH9WithdrawalEventArgs extends DecodedLogArgs { + _owner: string; + _value: BigNumber; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class WETH9Contract extends BaseContract { + public name = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public approve = { + async sendTransactionAsync( + guy: string, + wad: BigNumber, + 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, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + guy, + wad + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + guy: string, + wad: BigNumber, + 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, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + guy: string, + 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, + wad + ]); + return abiEncodedTransactionData; + }, + async callAsync( + guy: string, + wad: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + wad + ]); + 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: '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]; + }, + }; + public totalSupply = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transferFrom = { + async sendTransactionAsync( + src: string, + dst: string, + wad: BigNumber, + 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, + dst, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + src, + dst, + wad + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + src: string, + dst: string, + wad: BigNumber, + 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, + dst, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + src: string, + dst: string, + 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, + dst, + wad + ]); + return abiEncodedTransactionData; + }, + async callAsync( + src: string, + dst: string, + wad: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + dst, + wad + ]); + 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: '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]; + }, + }; + public withdraw = { + async sendTransactionAsync( + wad: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.withdraw.estimateGasAsync.bind( + self, + wad + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + wad: BigNumber, + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + 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 + ]); + return abiEncodedTransactionData; + }, + async callAsync( + wad: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'withdraw'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public decimals = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + index_0: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public symbol = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transfer = { + async sendTransactionAsync( + dst: string, + wad: BigNumber, + 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, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transfer.estimateGasAsync.bind( + self, + dst, + wad + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + dst: string, + wad: BigNumber, + 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, + wad + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + dst: string, + 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, + wad + ]); + return abiEncodedTransactionData; + }, + async callAsync( + dst: string, + wad: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + wad + ]); + 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: '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]; + }, + }; + public deposit = { + async sendTransactionAsync( + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.deposit.estimateGasAsync.bind( + self, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + 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([]); + return abiEncodedTransactionData; + }, + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: 'deposit'}) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); + resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); + return resultArray; + }, + }; + public allowance = { + async callAsync( + index_0: string, + index_1: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + index_1 + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<WETH9Contract> { + 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 WETH9Contract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<WETH9Contract> { + 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(`WETH9 successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new WETH9Contract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('WETH9', 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/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts new file mode 100644 index 000000000..98079e77b --- /dev/null +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -0,0 +1,646 @@ +// 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 { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; +// tslint:enable:no-unused-variable + +export type ZRXTokenEventArgs = + | ZRXTokenTransferEventArgs + | ZRXTokenApprovalEventArgs; + +export enum ZRXTokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', +} + +export interface ZRXTokenTransferEventArgs extends DecodedLogArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface ZRXTokenApprovalEventArgs extends DecodedLogArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class ZRXTokenContract extends BaseContract { + public name = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public approve = { + async sendTransactionAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.approve.estimateGasAsync.bind( + self, + _spender, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _spender: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _spender: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _spender: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public totalSupply = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _value: BigNumber, + 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, + _to, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _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, + _to, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _to, + _value + ]); + 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: '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]; + }, + }; + public decimals = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public symbol = { + async callAsync( + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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 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: '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]; + }, + }; + public transfer = { + async sendTransactionAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.transfer.estimateGasAsync.bind( + self, + _to, + _value + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _to: string, + _value: BigNumber, + 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, + _value + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _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, + _value + ]); + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _value: BigNumber, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _value + ]); + 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: '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]; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + callData: Partial<CallData> = {}, + defaultBlock?: BlockParam, + ): 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, + _spender + ]); + 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: '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]; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ZRXTokenContract> { + 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 ZRXTokenContract.deployAsync(bytecode, abi, provider, txDefaults, ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial<TxData>, + ): Promise<ZRXTokenContract> { + 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(`ZRXToken successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ZRXTokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults); + contractInstance.constructorArgs = []; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) { + super('ZRXToken', 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 new file mode 100644 index 000000000..de418214b --- /dev/null +++ b/packages/abi-gen-wrappers/src/index.ts @@ -0,0 +1,14 @@ +export * from './generated-wrappers/asset_proxy_owner'; +export * from './generated-wrappers/dummy_erc20_token'; +export * from './generated-wrappers/dummy_erc721_token'; +export * from './generated-wrappers/erc20_proxy'; +export * from './generated-wrappers/erc20_token'; +export * from './generated-wrappers/erc721_proxy'; +export * from './generated-wrappers/erc721_token'; +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/order_validator'; +export * from './generated-wrappers/weth9'; +export * from './generated-wrappers/zrx_token'; diff --git a/packages/abi-gen-wrappers/tsconfig.json b/packages/abi-gen-wrappers/tsconfig.json new file mode 100644 index 000000000..233008d61 --- /dev/null +++ b/packages/abi-gen-wrappers/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/abi-gen-wrappers/tslint.json b/packages/abi-gen-wrappers/tslint.json new file mode 100644 index 000000000..dd9053357 --- /dev/null +++ b/packages/abi-gen-wrappers/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} |