From 209266dbed9d7d038c90c2da8d9b99acab77c80c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 9 May 2018 20:36:28 +0200 Subject: Split 0x.js into contract-wrappers, order-watcher but keep 0x.js as a unifying library with the same interface --- .../src/contract_wrappers/generated/dummy_token.ts | 84 ++ .../src/contract_wrappers/generated/ether_token.ts | 621 +++++++++ .../src/contract_wrappers/generated/exchange.ts | 1459 ++++++++++++++++++++ .../src/contract_wrappers/generated/token.ts | 432 ++++++ .../contract_wrappers/generated/token_registry.ts | 799 +++++++++++ .../generated/token_transfer_proxy.ts | 447 ++++++ 6 files changed, 3842 insertions(+) create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/dummy_token.ts create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/ether_token.ts create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/exchange.ts create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/token.ts create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/token_registry.ts create mode 100644 packages/contract-wrappers/src/contract_wrappers/generated/token_transfer_proxy.ts (limited to 'packages/contract-wrappers/src/contract_wrappers/generated') diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/dummy_token.ts b/packages/contract-wrappers/src/contract_wrappers/generated/dummy_token.ts new file mode 100644 index 000000000..ca923c7c5 --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/dummy_token.ts @@ -0,0 +1,84 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +// tslint:disable:no-parameter-reassignment +export class DummyTokenContract extends BaseContract { + public setBalance = { + async sendTransactionAsync(_target: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as DummyTokenContract; + const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; + [_target, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_target, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('setBalance(address,uint256)') + .functions.setBalance(_target, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.setBalance.estimateGasAsync.bind(self, _target, _value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_target: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as DummyTokenContract; + const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; + [_target, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_target, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('setBalance(address,uint256)') + .functions.setBalance(_target, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_target: string, _value: BigNumber): string { + const self = (this as any) as DummyTokenContract; + const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs; + [_target, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_target, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('setBalance(address,uint256)') + .functions.setBalance(_target, _value).data; + return abiEncodedTransactionData; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/ether_token.ts b/packages/contract-wrappers/src/contract_wrappers/generated/ether_token.ts new file mode 100644 index 000000000..df95ba937 --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/ether_token.ts @@ -0,0 +1,621 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +export type EtherTokenContractEventArgs = + | TransferContractEventArgs + | ApprovalContractEventArgs + | DepositContractEventArgs + | WithdrawalContractEventArgs; + +export enum EtherTokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', + Deposit = 'Deposit', + Withdrawal = 'Withdrawal', +} + +export interface TransferContractEventArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface ApprovalContractEventArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + +export interface DepositContractEventArgs { + _owner: string; + _value: BigNumber; +} + +export interface WithdrawalContractEventArgs { + _owner: string; + _value: BigNumber; +} + +// tslint:disable:no-parameter-reassignment +export class EtherTokenContract extends BaseContract { + public name = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'name()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.name() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.approve.estimateGasAsync.bind(self, _spender, _value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_spender: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _spender: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'approve(address,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.approve(_spender, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'totalSupply()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.totalSupply() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, + ): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + 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 = {}, + ): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as EtherTokenContract; + 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), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.transferFrom(_from, _to, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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(amount: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; + [amount] = BaseContract._formatABIDataItemList( + inputAbi, + [amount], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw(amount).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.withdraw.estimateGasAsync.bind(self, amount), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(amount: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; + [amount] = BaseContract._formatABIDataItemList( + inputAbi, + [amount], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw(amount).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(amount: BigNumber): string { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('withdraw(uint256)').inputs; + [amount] = BaseContract._formatABIDataItemList( + inputAbi, + [amount], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('withdraw(uint256)') + .functions.withdraw(amount).data; + return abiEncodedTransactionData; + }, + }; + public decimals = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'decimals()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.decimals() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'balanceOf(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_owner] = BaseContract._formatABIDataItemList( + inputAbi, + [_owner], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.balanceOf(_owner) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'symbol()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.symbol() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value) + .data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.transfer.estimateGasAsync.bind(self, _to, _value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_to: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value) + .data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_to: string, _value: BigNumber): string { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transfer(address,uint256)') + .functions.transfer(_to, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'transfer(address,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.transfer(_to, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('deposit()').inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const encodedData = self._lookupEthersInterface('deposit()').functions.deposit().data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.deposit.estimateGasAsync.bind(self), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(txData: Partial = {}): Promise { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('deposit()').inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(this)); + const encodedData = self._lookupEthersInterface('deposit()').functions.deposit().data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(): string { + const self = (this as any) as EtherTokenContract; + const inputAbi = self._lookupAbi('deposit()').inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const abiEncodedTransactionData = self._lookupEthersInterface('deposit()').functions.deposit().data; + return abiEncodedTransactionData; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as EtherTokenContract; + const functionSignature = 'allowance(address,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_owner, _spender] = BaseContract._formatABIDataItemList( + inputAbi, + [_owner, _spender], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.allowance(_owner, _spender) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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]; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/exchange.ts b/packages/contract-wrappers/src/contract_wrappers/generated/exchange.ts new file mode 100644 index 000000000..da2fc1754 --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/exchange.ts @@ -0,0 +1,1459 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +export type ExchangeContractEventArgs = + | LogFillContractEventArgs + | LogCancelContractEventArgs + | LogErrorContractEventArgs; + +export enum ExchangeEvents { + LogFill = 'LogFill', + LogCancel = 'LogCancel', + LogError = 'LogError', +} + +export interface LogFillContractEventArgs { + maker: string; + taker: string; + feeRecipient: string; + makerToken: string; + takerToken: string; + filledMakerTokenAmount: BigNumber; + filledTakerTokenAmount: BigNumber; + paidMakerFee: BigNumber; + paidTakerFee: BigNumber; + tokens: string; + orderHash: string; +} + +export interface LogCancelContractEventArgs { + maker: string; + feeRecipient: string; + makerToken: string; + takerToken: string; + cancelledMakerTokenAmount: BigNumber; + cancelledTakerTokenAmount: BigNumber; + tokens: string; + orderHash: string; +} + +export interface LogErrorContractEventArgs { + errorId: number; + orderHash: string; +} + +// tslint:disable:no-parameter-reassignment +export class ExchangeContract extends BaseContract { + public isRoundingError = { + async callAsync( + numerator: BigNumber, + denominator: BigNumber, + target: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'isRoundingError(uint256,uint256,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [numerator, denominator, target] = BaseContract._formatABIDataItemList( + inputAbi, + [numerator, denominator, target], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.isRoundingError(numerator, denominator, target) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'isRoundingError' }) 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 filled = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + 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), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.filled(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 cancelled = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + 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), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.cancelled(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 fillOrdersUpTo = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ) + .functions.fillOrdersUpTo( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.fillOrdersUpTo.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ) + .functions.fillOrdersUpTo( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface( + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])', + ) + .functions.fillOrdersUpTo( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + return abiEncodedTransactionData; + }, + async callAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = + 'fillOrdersUpTo(address[5][],uint256[6][],uint256,bool,uint8[],bytes32[],bytes32[])'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.fillOrdersUpTo( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'fillOrdersUpTo' }) 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( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('cancelOrder(address[5],uint256[6],uint256)').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmount] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmount], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('cancelOrder(address[5],uint256[6],uint256)') + .functions.cancelOrder(orderAddresses, orderValues, cancelTakerTokenAmount).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.cancelOrder.estimateGasAsync.bind(self, orderAddresses, orderValues, cancelTakerTokenAmount), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('cancelOrder(address[5],uint256[6],uint256)').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmount] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmount], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('cancelOrder(address[5],uint256[6],uint256)') + .functions.cancelOrder(orderAddresses, orderValues, cancelTakerTokenAmount).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('cancelOrder(address[5],uint256[6],uint256)').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmount] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmount], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('cancelOrder(address[5],uint256[6],uint256)') + .functions.cancelOrder(orderAddresses, orderValues, cancelTakerTokenAmount).data; + return abiEncodedTransactionData; + }, + async callAsync( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'cancelOrder(address[5],uint256[6],uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [orderAddresses, orderValues, cancelTakerTokenAmount] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmount], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.cancelOrder(orderAddresses, orderValues, cancelTakerTokenAmount) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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[0]; + }, + }; + public ZRX_TOKEN_CONTRACT = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'ZRX_TOKEN_CONTRACT()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.ZRX_TOKEN_CONTRACT() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'ZRX_TOKEN_CONTRACT' }) 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 batchFillOrKillOrders = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ).inputs; + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrKillOrders(orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.batchFillOrKillOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmounts, + v, + r, + s, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ).inputs; + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrKillOrders(orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array, + r: string[], + s: string[], + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ).inputs; + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface( + 'batchFillOrKillOrders(address[5][],uint256[6][],uint256[],uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrKillOrders(orderAddresses, orderValues, fillTakerTokenAmounts, v, r, s).data; + return abiEncodedTransactionData; + }, + }; + public fillOrKillOrder = { + async sendTransactionAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number | BigNumber, + r: string, + s: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .inputs; + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .functions.fillOrKillOrder(orderAddresses, orderValues, fillTakerTokenAmount, v, r, s).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.fillOrKillOrder.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + v, + r, + s, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number | BigNumber, + r: string, + s: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .inputs; + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .functions.fillOrKillOrder(orderAddresses, orderValues, fillTakerTokenAmount, v, r, s).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number | BigNumber, + r: string, + s: string, + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .inputs; + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, fillTakerTokenAmount, v, r, s], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('fillOrKillOrder(address[5],uint256[6],uint256,uint8,bytes32,bytes32)') + .functions.fillOrKillOrder(orderAddresses, orderValues, fillTakerTokenAmount, v, r, s).data; + return abiEncodedTransactionData; + }, + }; + public getUnavailableTakerTokenAmount = { + async callAsync( + orderHash: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'getUnavailableTakerTokenAmount(bytes32)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [orderHash] = BaseContract._formatABIDataItemList( + inputAbi, + [orderHash], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getUnavailableTakerTokenAmount(orderHash) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getUnavailableTakerTokenAmount' }) 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( + signer: string, + hash: string, + v: number | BigNumber, + r: string, + s: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'isValidSignature(address,bytes32,uint8,bytes32,bytes32)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [signer, hash, v, r, s] = BaseContract._formatABIDataItemList( + inputAbi, + [signer, hash, v, r, s], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.isValidSignature(signer, hash, v, r, s) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 getPartialAmount = { + async callAsync( + numerator: BigNumber, + denominator: BigNumber, + target: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'getPartialAmount(uint256,uint256,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [numerator, denominator, target] = BaseContract._formatABIDataItemList( + inputAbi, + [numerator, denominator, target], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getPartialAmount(numerator, denominator, target) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getPartialAmount' }) 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 TOKEN_TRANSFER_PROXY_CONTRACT = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'TOKEN_TRANSFER_PROXY_CONTRACT()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.TOKEN_TRANSFER_PROXY_CONTRACT() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'TOKEN_TRANSFER_PROXY_CONTRACT' }) 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( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrders( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.batchFillOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrders( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array, + r: string[], + s: string[], + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface( + 'batchFillOrders(address[5][],uint256[6][],uint256[],bool,uint8[],bytes32[],bytes32[])', + ) + .functions.batchFillOrders( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + return abiEncodedTransactionData; + }, + }; + public batchCancelOrders = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('batchCancelOrders(address[5][],uint256[6][],uint256[])').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmounts] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmounts], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('batchCancelOrders(address[5][],uint256[6][],uint256[])') + .functions.batchCancelOrders(orderAddresses, orderValues, cancelTakerTokenAmounts).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.batchCancelOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + cancelTakerTokenAmounts, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('batchCancelOrders(address[5][],uint256[6][],uint256[])').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmounts] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmounts], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('batchCancelOrders(address[5][],uint256[6][],uint256[])') + .functions.batchCancelOrders(orderAddresses, orderValues, cancelTakerTokenAmounts).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('batchCancelOrders(address[5][],uint256[6][],uint256[])').inputs; + [orderAddresses, orderValues, cancelTakerTokenAmounts] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues, cancelTakerTokenAmounts], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('batchCancelOrders(address[5][],uint256[6][],uint256[])') + .functions.batchCancelOrders(orderAddresses, orderValues, cancelTakerTokenAmounts).data; + return abiEncodedTransactionData; + }, + }; + public fillOrder = { + async sendTransactionAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number | BigNumber, + r: string, + s: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .functions.fillOrder( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.fillOrder.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number | BigNumber, + r: string, + s: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .functions.fillOrder( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number | BigNumber, + r: string, + s: string, + ): string { + const self = (this as any) as ExchangeContract; + const inputAbi = self._lookupAbi('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)') + .functions.fillOrder( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ).data; + return abiEncodedTransactionData; + }, + async callAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number | BigNumber, + r: string, + s: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'fillOrder(address[5],uint256[6],uint256,bool,uint8,bytes32,bytes32)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ] = BaseContract._formatABIDataItemList( + inputAbi, + [ + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.fillOrder( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 getOrderHash = { + async callAsync( + orderAddresses: string[], + orderValues: BigNumber[], + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'getOrderHash(address[5],uint256[6])'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [orderAddresses, orderValues] = BaseContract._formatABIDataItemList( + inputAbi, + [orderAddresses, orderValues], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getOrderHash(orderAddresses, orderValues) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getOrderHash' }) 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 EXTERNAL_QUERY_GAS_LIMIT = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'EXTERNAL_QUERY_GAS_LIMIT()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.EXTERNAL_QUERY_GAS_LIMIT() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'EXTERNAL_QUERY_GAS_LIMIT' }) 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 VERSION = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as ExchangeContract; + const functionSignature = 'VERSION()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.VERSION() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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]; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/token.ts b/packages/contract-wrappers/src/contract_wrappers/generated/token.ts new file mode 100644 index 000000000..130265d4d --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/token.ts @@ -0,0 +1,432 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +export type TokenContractEventArgs = TransferContractEventArgs | ApprovalContractEventArgs; + +export enum TokenEvents { + Transfer = 'Transfer', + Approval = 'Approval', +} + +export interface TransferContractEventArgs { + _from: string; + _to: string; + _value: BigNumber; +} + +export interface ApprovalContractEventArgs { + _owner: string; + _spender: string; + _value: BigNumber; +} + +// tslint:disable:no-parameter-reassignment +export class TokenContract extends BaseContract { + public approve = { + async sendTransactionAsync(_spender: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.approve.estimateGasAsync.bind(self, _spender, _value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_spender: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('approve(address,uint256)').inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('approve(address,uint256)') + .functions.approve(_spender, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _spender: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenContract; + const functionSignature = 'approve(address,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_spender, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_spender, _value], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.approve(_spender, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenContract; + const functionSignature = 'totalSupply()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.totalSupply() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, + ): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + 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 = {}, + ): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs; + [_from, _to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_from, _to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transferFrom(address,address,uint256)') + .functions.transferFrom(_from, _to, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _from: string, + _to: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenContract; + 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), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.transferFrom(_from, _to, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenContract; + const functionSignature = 'balanceOf(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_owner] = BaseContract._formatABIDataItemList( + inputAbi, + [_owner], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.balanceOf(_owner) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value) + .data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.transfer.estimateGasAsync.bind(self, _to, _value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_to: string, _value: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value) + .data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_to: string, _value: BigNumber): string { + const self = (this as any) as TokenContract; + const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transfer(address,uint256)') + .functions.transfer(_to, _value).data; + return abiEncodedTransactionData; + }, + async callAsync( + _to: string, + _value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenContract; + const functionSignature = 'transfer(address,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_to, _value] = BaseContract._formatABIDataItemList( + inputAbi, + [_to, _value], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.transfer(_to, _value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenContract; + const functionSignature = 'allowance(address,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_owner, _spender] = BaseContract._formatABIDataItemList( + inputAbi, + [_owner, _spender], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.allowance(_owner, _spender) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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]; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/token_registry.ts b/packages/contract-wrappers/src/contract_wrappers/generated/token_registry.ts new file mode 100644 index 000000000..243f81088 --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/token_registry.ts @@ -0,0 +1,799 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +export type TokenRegistryContractEventArgs = + | LogAddTokenContractEventArgs + | LogRemoveTokenContractEventArgs + | LogTokenNameChangeContractEventArgs + | LogTokenSymbolChangeContractEventArgs + | LogTokenIpfsHashChangeContractEventArgs + | LogTokenSwarmHashChangeContractEventArgs; + +export enum TokenRegistryEvents { + LogAddToken = 'LogAddToken', + LogRemoveToken = 'LogRemoveToken', + LogTokenNameChange = 'LogTokenNameChange', + LogTokenSymbolChange = 'LogTokenSymbolChange', + LogTokenIpfsHashChange = 'LogTokenIpfsHashChange', + LogTokenSwarmHashChange = 'LogTokenSwarmHashChange', +} + +export interface LogAddTokenContractEventArgs { + token: string; + name: string; + symbol: string; + decimals: number; + ipfsHash: string; + swarmHash: string; +} + +export interface LogRemoveTokenContractEventArgs { + token: string; + name: string; + symbol: string; + decimals: number; + ipfsHash: string; + swarmHash: string; +} + +export interface LogTokenNameChangeContractEventArgs { + token: string; + oldName: string; + newName: string; +} + +export interface LogTokenSymbolChangeContractEventArgs { + token: string; + oldSymbol: string; + newSymbol: string; +} + +export interface LogTokenIpfsHashChangeContractEventArgs { + token: string; + oldIpfsHash: string; + newIpfsHash: string; +} + +export interface LogTokenSwarmHashChangeContractEventArgs { + token: string; + oldSwarmHash: string; + newSwarmHash: string; +} + +// tslint:disable:no-parameter-reassignment +export class TokenRegistryContract extends BaseContract { + public removeToken = { + async sendTransactionAsync(_token: string, _index: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs; + [_token, _index] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _index], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('removeToken(address,uint256)') + .functions.removeToken(_token, _index).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.removeToken.estimateGasAsync.bind(self, _token, _index), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_token: string, _index: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs; + [_token, _index] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _index], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('removeToken(address,uint256)') + .functions.removeToken(_token, _index).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_token: string, _index: BigNumber): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs; + [_token, _index] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _index], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('removeToken(address,uint256)') + .functions.removeToken(_token, _index).data; + return abiEncodedTransactionData; + }, + }; + public getTokenAddressByName = { + async callAsync(_name: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenAddressByName(string)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_name] = BaseContract._formatABIDataItemList( + inputAbi, + [_name], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenAddressByName(_name) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenAddressByName' }) 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 getTokenAddressBySymbol = { + async callAsync(_symbol: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenAddressBySymbol(string)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_symbol] = BaseContract._formatABIDataItemList( + inputAbi, + [_symbol], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenAddressBySymbol(_symbol) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenAddressBySymbol' }) 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 setTokenSwarmHash = { + async sendTransactionAsync(_token: string, _swarmHash: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs; + [_token, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _swarmHash], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('setTokenSwarmHash(address,bytes)') + .functions.setTokenSwarmHash(_token, _swarmHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.setTokenSwarmHash.estimateGasAsync.bind(self, _token, _swarmHash), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_token: string, _swarmHash: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs; + [_token, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _swarmHash], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('setTokenSwarmHash(address,bytes)') + .functions.setTokenSwarmHash(_token, _swarmHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_token: string, _swarmHash: string): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs; + [_token, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _swarmHash], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('setTokenSwarmHash(address,bytes)') + .functions.setTokenSwarmHash(_token, _swarmHash).data; + return abiEncodedTransactionData; + }, + }; + public getTokenMetaData = { + async callAsync( + _token: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, number, string, string]> { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenMetaData(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_token] = BaseContract._formatABIDataItemList( + inputAbi, + [_token], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenMetaData(_token) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenMetaData' }) 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 = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'owner()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.owner() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 addToken = { + async sendTransactionAsync( + _token: string, + _name: string, + _symbol: string, + _decimals: number | BigNumber, + _ipfsHash: string, + _swarmHash: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs; + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)') + .functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.addToken.estimateGasAsync.bind(self, _token, _name, _symbol, _decimals, _ipfsHash, _swarmHash), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + _token: string, + _name: string, + _symbol: string, + _decimals: number | BigNumber, + _ipfsHash: string, + _swarmHash: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs; + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)') + .functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _name: string, + _symbol: string, + _decimals: number | BigNumber, + _ipfsHash: string, + _swarmHash: string, + ): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs; + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)') + .functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data; + return abiEncodedTransactionData; + }, + }; + public setTokenName = { + async sendTransactionAsync(_token: string, _name: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs; + [_token, _name] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('setTokenName(address,string)') + .functions.setTokenName(_token, _name).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.setTokenName.estimateGasAsync.bind(self, _token, _name), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_token: string, _name: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs; + [_token, _name] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('setTokenName(address,string)') + .functions.setTokenName(_token, _name).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_token: string, _name: string): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs; + [_token, _name] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _name], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('setTokenName(address,string)') + .functions.setTokenName(_token, _name).data; + return abiEncodedTransactionData; + }, + }; + public tokens = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, number, string, string]> { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'tokens(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.tokens(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'tokens' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public tokenAddresses = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'tokenAddresses(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.tokenAddresses(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'tokenAddresses' }) 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 getTokenByName = { + async callAsync( + _name: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, number, string, string]> { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenByName(string)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_name] = BaseContract._formatABIDataItemList( + inputAbi, + [_name], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenByName(_name) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenByName' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public getTokenAddresses = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenAddresses()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenAddresses() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenAddresses' }) 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 setTokenIpfsHash = { + async sendTransactionAsync(_token: string, _ipfsHash: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs; + [_token, _ipfsHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _ipfsHash], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('setTokenIpfsHash(address,bytes)') + .functions.setTokenIpfsHash(_token, _ipfsHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.setTokenIpfsHash.estimateGasAsync.bind(self, _token, _ipfsHash), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_token: string, _ipfsHash: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs; + [_token, _ipfsHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _ipfsHash], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('setTokenIpfsHash(address,bytes)') + .functions.setTokenIpfsHash(_token, _ipfsHash).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_token: string, _ipfsHash: string): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs; + [_token, _ipfsHash] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _ipfsHash], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('setTokenIpfsHash(address,bytes)') + .functions.setTokenIpfsHash(_token, _ipfsHash).data; + return abiEncodedTransactionData; + }, + }; + public getTokenBySymbol = { + async callAsync( + _symbol: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, number, string, string]> { + const self = (this as any) as TokenRegistryContract; + const functionSignature = 'getTokenBySymbol(string)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_symbol] = BaseContract._formatABIDataItemList( + inputAbi, + [_symbol], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getTokenBySymbol(_symbol) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTokenBySymbol' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public setTokenSymbol = { + async sendTransactionAsync(_token: string, _symbol: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs; + [_token, _symbol] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _symbol], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('setTokenSymbol(address,string)') + .functions.setTokenSymbol(_token, _symbol).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.setTokenSymbol.estimateGasAsync.bind(self, _token, _symbol), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_token: string, _symbol: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs; + [_token, _symbol] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _symbol], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('setTokenSymbol(address,string)') + .functions.setTokenSymbol(_token, _symbol).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_token: string, _symbol: string): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs; + [_token, _symbol] = BaseContract._formatABIDataItemList( + inputAbi, + [_token, _symbol], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('setTokenSymbol(address,string)') + .functions.setTokenSymbol(_token, _symbol).data; + return abiEncodedTransactionData; + }, + }; + public transferOwnership = { + async sendTransactionAsync(newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.transferOwnership.estimateGasAsync.bind(self, newOwner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(newOwner: string): string { + const self = (this as any) as TokenRegistryContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + return abiEncodedTransactionData; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contract-wrappers/src/contract_wrappers/generated/token_transfer_proxy.ts b/packages/contract-wrappers/src/contract_wrappers/generated/token_transfer_proxy.ts new file mode 100644 index 000000000..e533430ff --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/generated/token_transfer_proxy.ts @@ -0,0 +1,447 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. + */ +// tslint:disable:no-consecutive-blank-lines +// tslint:disable-next-line:no-unused-variable +import { BaseContract } from '@0xproject/base-contract'; +import { + BlockParam, + BlockParamLiteral, + CallData, + ContractAbi, + DataItem, + MethodAbi, + Provider, + TxData, + TxDataPayable, +} from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as ethers from 'ethers'; +import * as _ from 'lodash'; + +export type TokenTransferProxyContractEventArgs = + | LogAuthorizedAddressAddedContractEventArgs + | LogAuthorizedAddressRemovedContractEventArgs; + +export enum TokenTransferProxyEvents { + LogAuthorizedAddressAdded = 'LogAuthorizedAddressAdded', + LogAuthorizedAddressRemoved = 'LogAuthorizedAddressRemoved', +} + +export interface LogAuthorizedAddressAddedContractEventArgs { + target: string; + caller: string; +} + +export interface LogAuthorizedAddressRemovedContractEventArgs { + target: string; + caller: string; +} + +// tslint:disable:no-parameter-reassignment +export class TokenTransferProxyContract extends BaseContract { + public transferFrom = { + async sendTransactionAsync( + token: string, + from: string, + to: string, + value: BigNumber, + txData: Partial = {}, + ): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs; + [token, from, to, value] = BaseContract._formatABIDataItemList( + inputAbi, + [token, from, to, value], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,address,uint256)') + .functions.transferFrom(token, from, to, value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.transferFrom.estimateGasAsync.bind(self, token, from, to, value), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + token: string, + from: string, + to: string, + value: BigNumber, + txData: Partial = {}, + ): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs; + [token, from, to, value] = BaseContract._formatABIDataItemList( + inputAbi, + [token, from, to, value], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('transferFrom(address,address,address,uint256)') + .functions.transferFrom(token, from, to, value).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(token: string, from: string, to: string, value: BigNumber): string { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs; + [token, from, to, value] = BaseContract._formatABIDataItemList( + inputAbi, + [token, from, to, value], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transferFrom(address,address,address,uint256)') + .functions.transferFrom(token, from, to, value).data; + return abiEncodedTransactionData; + }, + async callAsync( + token: string, + from: string, + to: string, + value: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenTransferProxyContract; + const functionSignature = 'transferFrom(address,address,address,uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [token, from, to, value] = BaseContract._formatABIDataItemList( + inputAbi, + [token, from, to, value], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.transferFrom(token, from, to, value) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 addAuthorizedAddress = { + async sendTransactionAsync(target: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('addAuthorizedAddress(address)') + .functions.addAuthorizedAddress(target).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.addAuthorizedAddress.estimateGasAsync.bind(self, target), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(target: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('addAuthorizedAddress(address)') + .functions.addAuthorizedAddress(target).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(target: string): string { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('addAuthorizedAddress(address)') + .functions.addAuthorizedAddress(target).data; + return abiEncodedTransactionData; + }, + }; + public authorities = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenTransferProxyContract; + const functionSignature = 'authorities(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.authorities(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('removeAuthorizedAddress(address)') + .functions.removeAuthorizedAddress(target).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.removeAuthorizedAddress.estimateGasAsync.bind(self, target), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(target: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('removeAuthorizedAddress(address)') + .functions.removeAuthorizedAddress(target).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(target: string): string { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs; + [target] = BaseContract._formatABIDataItemList( + inputAbi, + [target], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('removeAuthorizedAddress(address)') + .functions.removeAuthorizedAddress(target).data; + return abiEncodedTransactionData; + }, + }; + public owner = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenTransferProxyContract; + const functionSignature = 'owner()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.owner() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 authorized = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as TokenTransferProxyContract; + const functionSignature = 'authorized(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.authorized(index_0) as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as TokenTransferProxyContract; + const functionSignature = 'getAuthorizedAddresses()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + const ethersFunction = self + ._lookupEthersInterface(functionSignature) + .functions.getAuthorizedAddresses() as ethers.CallDescription; + const encodedData = ethersFunction.data; + const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: encodedData, + }); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + let resultArray = ethersFunction.parse(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 = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(self), + ); + const encodedData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + { + ...txData, + data: encodedData, + }, + self.transferOwnership.estimateGasAsync.bind(self, newOwner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(this), + ); + const encodedData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + ...txData, + data: encodedData, + }); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(newOwner: string): string { + const self = (this as any) as TokenTransferProxyContract; + const inputAbi = self._lookupAbi('transferOwnership(address)').inputs; + [newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [newOwner], + BaseContract._bigNumberToString.bind(self), + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('transferOwnership(address)') + .functions.transferOwnership(newOwner).data; + return abiEncodedTransactionData; + }, + }; + constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial) { + super(abi, address, provider, defaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count -- cgit